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

Move icons #1169

Merged
merged 5 commits into from
Sep 14, 2023
Merged

Move icons #1169

merged 5 commits into from
Sep 14, 2023

Conversation

jlvandenhout
Copy link
Contributor

@jlvandenhout jlvandenhout commented Sep 14, 2023

Description of change

This moves the icons to the static folder and adjusts import accordingly. All icon SVG files are now in static/icons. For convenience, they are also still exposed as part of the object exported by src/icons. The keys of the object are the CamelCased versions of the SVG filenames, for example IotaCore corresponds to static/icons/iota/iota-core.svg.

The reason for this is now we can also statically reference the icon images if needed and it allows dynamic lookup of icons that are statically configured, while still being able to inline them. For example we can now do something like:

themeConfig: {
  icon: 'IotaCore',
},

and use that to dynamically look up the icon in React, i.e.:

import useThemeConfig from '@docusaurus/useThemeConfig';
import icons from '@site/src/icons';

export function Icon() {
  const { icon } = useThemeConfig();
  const SVG = icons[icon];

  return <SVG />
}

This will render the SVG inline, so CSS styling works.

Type of change

  • Enhancement (a non-breaking change which adds functionality)

Change checklist

Tick the boxes that are relevant to your changes, and delete any items that are not.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own changes
  • I have made sure that added/changed links still work

@Dr-Electron
Copy link
Collaborator

/create-preview

@github-actions
Copy link
Contributor

This pull request has been deployed to Vercel.

Latest commit:

✅ Preview: https://iota-wiki-2yskxunn0-iota1.vercel.app

@Dr-Electron Dr-Electron merged commit 528984c into main Sep 14, 2023
@Dr-Electron Dr-Electron deleted the feat/move-icons branch September 14, 2023 22:41
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

Successfully merging this pull request may close these issues.

2 participants