Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use both solid and outlined font icons #363

Open
stonetip opened this issue Feb 2, 2024 · 6 comments
Open

Add ability to use both solid and outlined font icons #363

stonetip opened this issue Feb 2, 2024 · 6 comments

Comments

@stonetip
Copy link

stonetip commented Feb 2, 2024

It would be helpful to be able to use either solid or outlined versions of icons in the same web page. I would be happy to submit a pull request if this is considered a valid issue. I very much appreciate the work that went into providing this excellent resource.

As defined currently, unless I'm mistaken, this isn't possible. I was able to achieve this by making just three modifications. In the modus-outlined/fonts directory, I modified the CSS file:

@font-face {
  font-family: "modus-icons-outlined";
...
}

.modus-icons-outlined {
  font-family: "modus-icons-outlined";
...
}

I could then reference the icons like this in the same web page:

<i class="modus-icons">map</i>
<i class="modus-icons-outlined">map</i>
...
image
@coliff
Copy link
Member

coliff commented Mar 11, 2024

Firstly - Sorry for the long delay in replying! The original intention for the Modus Icon sets were that a single set was to be used per app/site and they shouldn't be mixed & matched.

We realise there are instances were it makes sense to use some icons from both sets though.

We don't have official guidance on an implementation method for this at the moment, but the way you are handling it looks good - that's what I would have done. :-)

@jmecosta
Copy link

jmecosta commented Aug 6, 2024

We also have the same need. Would be nice if this could be decided

@coliff coliff pinned this issue Sep 11, 2024
@gabriel-piltzer-trimble

Upvoting this. We also have the same need.

@stonetip
Copy link
Author

stonetip commented Nov 13, 2024

Here's what we do to mix and match the sets (which I believe will remove the need for any action on your part - other than maybe adding some documentation somewhere):

  1. After installing (in our case, using Yarn) we run a postinstall in package.json to copy modus-icons over to public:
    "scripts": {
"postinstall": "shx mkdir -p public/modus-icons && shx cp -r node_modules/@trimble-oss/modus-icons public/"
  1. Each set of icons is referenced in an HTML page that requires them:
<link rel="stylesheet" href="/modus-icons/dist/modus-outlined/fonts/modus-icons.css" />
<link rel="stylesheet" href="/modus-icons/dist/transportation/fonts/modus-icons.css" />
  1. We've found it easiest to use icons this way, but there are others (per general documentation). They can be used on the same page since the paths are specific:
    <svg class="icon button">
        <use href="/modus-icons/dist/transportation/sprites/modus-icons.svg#edit"/>
    </svg>
    <svg class="icon button">
        <use href="/modus-icons/dist/modus-outlined//sprites/modus-icons.svg#edit"/>
    </svg>
  1. Programatically, we use code like this:
	const selectionContainer = document.createElement("div");
	const selectionToggle = document.createElementNS("http://www.w3.org/2000/svg", "svg");
	const selectionUseElement = document.createElementNS("http://www.w3.org/2000/svg", "use");

	selectionContainer.classList.add("list-item-section");
	selectionToggle.classList.add("icon", "button", "plain");
	selectionUseElement.setAttributeNS(null, "href", "/modus-icons/dist/modus-outlined/sprites/modus-icons.svg#check-circle-outlined");

	selectionToggle.appendChild(selectionUseElement);
	selectionContainer.appendChild(selectionToggle);

@gabriel-piltzer-trimble

How would you achieve this when referencing modus-icons from a CDN like jsDelivr?
@stonetip

@stonetip
Copy link
Author

stonetip commented Nov 13, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants