From 84927bbba2fe8b204747ad30d9913e902257568c Mon Sep 17 00:00:00 2001 From: Jeroen van den Hout Date: Sat, 2 Sep 2023 11:39:21 +0200 Subject: [PATCH 1/5] Move icons --- src/common/icons/iota/index.ts | 44 +++++++++---------- src/common/icons/socials/index.ts | 16 +++---- {src/common => static}/icons/iota/bee.svg | 0 .../icons/iota/chronicle.svg | 0 .../icons/iota/chrysalis.svg | 0 .../icons/iota/getting_started.svg | 0 .../icons/iota/go_shimmer.svg | 0 {src/common => static}/icons/iota/hornet.svg | 0 .../common => static}/icons/iota/identity.svg | 0 .../icons/iota/integration_services.svg | 0 {src/common => static}/icons/iota/iota_20.svg | 0 .../icons/iota/iota_core.svg | 0 .../icons/iota/iota_token.svg | 0 {src/common => static}/icons/iota/next.svg | 0 .../icons/iota/pick_a_wallet.svg | 0 {src/common => static}/icons/iota/search.svg | 0 {src/common => static}/icons/iota/shimmer.svg | 0 .../icons/iota/smart_contracts.svg | 0 {src/common => static}/icons/iota/streams.svg | 0 .../icons/iota/stronghold.svg | 0 {src/common => static}/icons/iota/tips.svg | 0 {src/common => static}/icons/iota/tools.svg | 0 .../icons/iota/tutorials.svg | 0 {src/common => static}/icons/iota/wallet.svg | 0 {src/common => static}/icons/iota/wasp.svg | 0 .../icons/socials/discord.svg | 0 .../icons/socials/facebook.svg | 0 .../icons/socials/github.svg | 0 .../icons/socials/instagram.svg | 0 .../icons/socials/linkedin.svg | 0 .../icons/socials/reddit.svg | 0 .../icons/socials/twitter.svg | 0 .../icons/socials/youtube.svg | 0 33 files changed, 30 insertions(+), 30 deletions(-) rename {src/common => static}/icons/iota/bee.svg (100%) rename {src/common => static}/icons/iota/chronicle.svg (100%) rename {src/common => static}/icons/iota/chrysalis.svg (100%) rename {src/common => static}/icons/iota/getting_started.svg (100%) rename {src/common => static}/icons/iota/go_shimmer.svg (100%) rename {src/common => static}/icons/iota/hornet.svg (100%) rename {src/common => static}/icons/iota/identity.svg (100%) rename {src/common => static}/icons/iota/integration_services.svg (100%) rename {src/common => static}/icons/iota/iota_20.svg (100%) rename {src/common => static}/icons/iota/iota_core.svg (100%) rename {src/common => static}/icons/iota/iota_token.svg (100%) rename {src/common => static}/icons/iota/next.svg (100%) rename {src/common => static}/icons/iota/pick_a_wallet.svg (100%) rename {src/common => static}/icons/iota/search.svg (100%) rename {src/common => static}/icons/iota/shimmer.svg (100%) rename {src/common => static}/icons/iota/smart_contracts.svg (100%) rename {src/common => static}/icons/iota/streams.svg (100%) rename {src/common => static}/icons/iota/stronghold.svg (100%) rename {src/common => static}/icons/iota/tips.svg (100%) rename {src/common => static}/icons/iota/tools.svg (100%) rename {src/common => static}/icons/iota/tutorials.svg (100%) rename {src/common => static}/icons/iota/wallet.svg (100%) rename {src/common => static}/icons/iota/wasp.svg (100%) rename {src/common => static}/icons/socials/discord.svg (100%) rename {src/common => static}/icons/socials/facebook.svg (100%) rename {src/common => static}/icons/socials/github.svg (100%) rename {src/common => static}/icons/socials/instagram.svg (100%) rename {src/common => static}/icons/socials/linkedin.svg (100%) rename {src/common => static}/icons/socials/reddit.svg (100%) rename {src/common => static}/icons/socials/twitter.svg (100%) rename {src/common => static}/icons/socials/youtube.svg (100%) diff --git a/src/common/icons/iota/index.ts b/src/common/icons/iota/index.ts index 2dcbccd9501..22c0d138461 100644 --- a/src/common/icons/iota/index.ts +++ b/src/common/icons/iota/index.ts @@ -1,22 +1,22 @@ -export { default as Chronicle } from './chronicle.svg'; -export { default as Chrysalis } from './chrysalis.svg'; -export { default as GettingStarted } from './getting_started.svg'; -export { default as GoShimmer } from './go_shimmer.svg'; -export { default as Hornet } from './hornet.svg'; -export { default as Identity } from './identity.svg'; -export { default as IntegrationServices } from './integration_services.svg'; -export { default as Iota20 } from './iota_20.svg'; -export { default as IotaCore } from './iota_core.svg'; -export { default as IotaToken } from './iota_token.svg'; -export { default as Next } from './next.svg'; -export { default as PickAWallet } from './pick_a_wallet.svg'; -export { default as Search } from './search.svg'; -export { default as Shimmer } from './shimmer.svg'; -export { default as SmartContracts } from './smart_contracts.svg'; -export { default as Streams } from './streams.svg'; -export { default as Stronghold } from './stronghold.svg'; -export { default as Tips } from './tips.svg'; -export { default as Tools } from './tools.svg'; -export { default as Tutorials } from './tutorials.svg'; -export { default as Wallet } from './wallet.svg'; -export { default as Wasp } from './wasp.svg'; +export { default as Chronicle } from '@site/static/icons/iota/chronicle.svg'; +export { default as Chrysalis } from '@site/static/icons/iota/chrysalis.svg'; +export { default as GettingStarted } from '@site/static/icons/iota/getting_started.svg'; +export { default as GoShimmer } from '@site/static/icons/iota/go_shimmer.svg'; +export { default as Hornet } from '@site/static/icons/iota/hornet.svg'; +export { default as Identity } from '@site/static/icons/iota/identity.svg'; +export { default as IntegrationServices } from '@site/static/icons/iota/integration_services.svg'; +export { default as Iota20 } from '@site/static/icons/iota/iota_20.svg'; +export { default as IotaCore } from '@site/static/icons/iota/iota_core.svg'; +export { default as IotaToken } from '@site/static/icons/iota/iota_token.svg'; +export { default as Next } from '@site/static/icons/iota/next.svg'; +export { default as PickAWallet } from '@site/static/icons/iota/pick_a_wallet.svg'; +export { default as Search } from '@site/static/icons/iota/search.svg'; +export { default as Shimmer } from '@site/static/icons/iota/shimmer.svg'; +export { default as SmartContracts } from '@site/static/icons/iota/smart_contracts.svg'; +export { default as Streams } from '@site/static/icons/iota/streams.svg'; +export { default as Stronghold } from '@site/static/icons/iota/stronghold.svg'; +export { default as Tips } from '@site/static/icons/iota/tips.svg'; +export { default as Tools } from '@site/static/icons/iota/tools.svg'; +export { default as Tutorials } from '@site/static/icons/iota/tutorials.svg'; +export { default as Wallet } from '@site/static/icons/iota/wallet.svg'; +export { default as Wasp } from '@site/static/icons/iota/wasp.svg'; diff --git a/src/common/icons/socials/index.ts b/src/common/icons/socials/index.ts index 0359178b283..d451c56e24e 100644 --- a/src/common/icons/socials/index.ts +++ b/src/common/icons/socials/index.ts @@ -1,8 +1,8 @@ -export { default as Discord } from './discord.svg'; -export { default as Facebook } from './facebook.svg'; -export { default as Github } from './github.svg'; -export { default as Instagram } from './instagram.svg'; -export { default as LinkedIn } from './linkedin.svg'; -export { default as Reddit } from './reddit.svg'; -export { default as Twitter } from './twitter.svg'; -export { default as Youtube } from './youtube.svg'; +export { default as Discord } from '@site/static/icons/socials/discord.svg'; +export { default as Facebook } from '@site/static/icons/socials/facebook.svg'; +export { default as Github } from '@site/static/icons/socials/github.svg'; +export { default as Instagram } from '@site/static/icons/socials/instagram.svg'; +export { default as LinkedIn } from '@site/static/icons/socials/linkedin.svg'; +export { default as Reddit } from '@site/static/icons/socials/reddit.svg'; +export { default as Twitter } from '@site/static/icons/socials/twitter.svg'; +export { default as Youtube } from '@site/static/icons/socials/youtube.svg'; diff --git a/src/common/icons/iota/bee.svg b/static/icons/iota/bee.svg similarity index 100% rename from src/common/icons/iota/bee.svg rename to static/icons/iota/bee.svg diff --git a/src/common/icons/iota/chronicle.svg b/static/icons/iota/chronicle.svg similarity index 100% rename from src/common/icons/iota/chronicle.svg rename to static/icons/iota/chronicle.svg diff --git a/src/common/icons/iota/chrysalis.svg b/static/icons/iota/chrysalis.svg similarity index 100% rename from src/common/icons/iota/chrysalis.svg rename to static/icons/iota/chrysalis.svg diff --git a/src/common/icons/iota/getting_started.svg b/static/icons/iota/getting_started.svg similarity index 100% rename from src/common/icons/iota/getting_started.svg rename to static/icons/iota/getting_started.svg diff --git a/src/common/icons/iota/go_shimmer.svg b/static/icons/iota/go_shimmer.svg similarity index 100% rename from src/common/icons/iota/go_shimmer.svg rename to static/icons/iota/go_shimmer.svg diff --git a/src/common/icons/iota/hornet.svg b/static/icons/iota/hornet.svg similarity index 100% rename from src/common/icons/iota/hornet.svg rename to static/icons/iota/hornet.svg diff --git a/src/common/icons/iota/identity.svg b/static/icons/iota/identity.svg similarity index 100% rename from src/common/icons/iota/identity.svg rename to static/icons/iota/identity.svg diff --git a/src/common/icons/iota/integration_services.svg b/static/icons/iota/integration_services.svg similarity index 100% rename from src/common/icons/iota/integration_services.svg rename to static/icons/iota/integration_services.svg diff --git a/src/common/icons/iota/iota_20.svg b/static/icons/iota/iota_20.svg similarity index 100% rename from src/common/icons/iota/iota_20.svg rename to static/icons/iota/iota_20.svg diff --git a/src/common/icons/iota/iota_core.svg b/static/icons/iota/iota_core.svg similarity index 100% rename from src/common/icons/iota/iota_core.svg rename to static/icons/iota/iota_core.svg diff --git a/src/common/icons/iota/iota_token.svg b/static/icons/iota/iota_token.svg similarity index 100% rename from src/common/icons/iota/iota_token.svg rename to static/icons/iota/iota_token.svg diff --git a/src/common/icons/iota/next.svg b/static/icons/iota/next.svg similarity index 100% rename from src/common/icons/iota/next.svg rename to static/icons/iota/next.svg diff --git a/src/common/icons/iota/pick_a_wallet.svg b/static/icons/iota/pick_a_wallet.svg similarity index 100% rename from src/common/icons/iota/pick_a_wallet.svg rename to static/icons/iota/pick_a_wallet.svg diff --git a/src/common/icons/iota/search.svg b/static/icons/iota/search.svg similarity index 100% rename from src/common/icons/iota/search.svg rename to static/icons/iota/search.svg diff --git a/src/common/icons/iota/shimmer.svg b/static/icons/iota/shimmer.svg similarity index 100% rename from src/common/icons/iota/shimmer.svg rename to static/icons/iota/shimmer.svg diff --git a/src/common/icons/iota/smart_contracts.svg b/static/icons/iota/smart_contracts.svg similarity index 100% rename from src/common/icons/iota/smart_contracts.svg rename to static/icons/iota/smart_contracts.svg diff --git a/src/common/icons/iota/streams.svg b/static/icons/iota/streams.svg similarity index 100% rename from src/common/icons/iota/streams.svg rename to static/icons/iota/streams.svg diff --git a/src/common/icons/iota/stronghold.svg b/static/icons/iota/stronghold.svg similarity index 100% rename from src/common/icons/iota/stronghold.svg rename to static/icons/iota/stronghold.svg diff --git a/src/common/icons/iota/tips.svg b/static/icons/iota/tips.svg similarity index 100% rename from src/common/icons/iota/tips.svg rename to static/icons/iota/tips.svg diff --git a/src/common/icons/iota/tools.svg b/static/icons/iota/tools.svg similarity index 100% rename from src/common/icons/iota/tools.svg rename to static/icons/iota/tools.svg diff --git a/src/common/icons/iota/tutorials.svg b/static/icons/iota/tutorials.svg similarity index 100% rename from src/common/icons/iota/tutorials.svg rename to static/icons/iota/tutorials.svg diff --git a/src/common/icons/iota/wallet.svg b/static/icons/iota/wallet.svg similarity index 100% rename from src/common/icons/iota/wallet.svg rename to static/icons/iota/wallet.svg diff --git a/src/common/icons/iota/wasp.svg b/static/icons/iota/wasp.svg similarity index 100% rename from src/common/icons/iota/wasp.svg rename to static/icons/iota/wasp.svg diff --git a/src/common/icons/socials/discord.svg b/static/icons/socials/discord.svg similarity index 100% rename from src/common/icons/socials/discord.svg rename to static/icons/socials/discord.svg diff --git a/src/common/icons/socials/facebook.svg b/static/icons/socials/facebook.svg similarity index 100% rename from src/common/icons/socials/facebook.svg rename to static/icons/socials/facebook.svg diff --git a/src/common/icons/socials/github.svg b/static/icons/socials/github.svg similarity index 100% rename from src/common/icons/socials/github.svg rename to static/icons/socials/github.svg diff --git a/src/common/icons/socials/instagram.svg b/static/icons/socials/instagram.svg similarity index 100% rename from src/common/icons/socials/instagram.svg rename to static/icons/socials/instagram.svg diff --git a/src/common/icons/socials/linkedin.svg b/static/icons/socials/linkedin.svg similarity index 100% rename from src/common/icons/socials/linkedin.svg rename to static/icons/socials/linkedin.svg diff --git a/src/common/icons/socials/reddit.svg b/static/icons/socials/reddit.svg similarity index 100% rename from src/common/icons/socials/reddit.svg rename to static/icons/socials/reddit.svg diff --git a/src/common/icons/socials/twitter.svg b/static/icons/socials/twitter.svg similarity index 100% rename from src/common/icons/socials/twitter.svg rename to static/icons/socials/twitter.svg diff --git a/src/common/icons/socials/youtube.svg b/static/icons/socials/youtube.svg similarity index 100% rename from src/common/icons/socials/youtube.svg rename to static/icons/socials/youtube.svg From 6bc6b25d9d0069732b050e81505761b0af6d069b Mon Sep 17 00:00:00 2001 From: Jeroen van den Hout Date: Thu, 14 Sep 2023 16:03:14 +0200 Subject: [PATCH 2/5] Move icon directory up and fix imports --- src/common/components/CustomNetworkDropdown/index.tsx | 2 +- src/components/HomeLayout/AppLibrariesSection.tsx | 7 +------ src/components/HomeLayout/CoreLibrariesSection.tsx | 2 +- src/components/HomeLayout/index.tsx | 2 +- src/{common => }/icons/index.ts | 0 src/{common => }/icons/iota/index.ts | 0 src/{common => }/icons/socials/index.ts | 0 src/switcher.config.ts | 2 +- src/utils/socials.ts | 2 +- 9 files changed, 6 insertions(+), 11 deletions(-) rename src/{common => }/icons/index.ts (100%) rename src/{common => }/icons/iota/index.ts (100%) rename src/{common => }/icons/socials/index.ts (100%) diff --git a/src/common/components/CustomNetworkDropdown/index.tsx b/src/common/components/CustomNetworkDropdown/index.tsx index 948d39e04f4..0883d87b3ff 100644 --- a/src/common/components/CustomNetworkDropdown/index.tsx +++ b/src/common/components/CustomNetworkDropdown/index.tsx @@ -12,7 +12,7 @@ import type { } from '@theme/NavbarItem/DropdownNavbarItem'; import './styles.css'; -import { IotaCore, Shimmer, Next } from '../../icons'; +import { IotaCore, Shimmer, Next } from '@site/src/icons'; import { fetchSitemapUrlsFromNetwork, getBestNetworkUrlMatch, diff --git a/src/components/HomeLayout/AppLibrariesSection.tsx b/src/components/HomeLayout/AppLibrariesSection.tsx index be9f31ff2dd..9ba8ed253e9 100644 --- a/src/components/HomeLayout/AppLibrariesSection.tsx +++ b/src/components/HomeLayout/AppLibrariesSection.tsx @@ -1,11 +1,6 @@ import React, { FC } from 'react'; import Link from '@docusaurus/Link'; -import { - Identity, - SmartContracts, - Streams, - Stronghold, -} from '@site/src/common/icons'; +import { Identity, SmartContracts, Streams, Stronghold } from '@site/src/icons'; interface LanguagesProps { languages?: { [key: string]: string }; diff --git a/src/components/HomeLayout/CoreLibrariesSection.tsx b/src/components/HomeLayout/CoreLibrariesSection.tsx index a58c5ef7bf6..674e5bcd97b 100644 --- a/src/components/HomeLayout/CoreLibrariesSection.tsx +++ b/src/components/HomeLayout/CoreLibrariesSection.tsx @@ -3,7 +3,7 @@ import CoreLibImgDark from '@site/static/img/homepage/section_core_libraries_dar import ThemedImage from '@theme/ThemedImage'; import React, { FC } from 'react'; import Link from '@docusaurus/Link'; -import { Shimmer } from '@site/src/common/icons'; +import { Shimmer } from '@site/src/icons'; interface LanguagesProps { languages?: { [key: string]: string }; diff --git a/src/components/HomeLayout/index.tsx b/src/components/HomeLayout/index.tsx index e9f3c6f7e63..75204767767 100644 --- a/src/components/HomeLayout/index.tsx +++ b/src/components/HomeLayout/index.tsx @@ -19,7 +19,7 @@ import { Tips, Tutorials, Wasp, -} from '@site/src/common/icons'; +} from '@site/src/icons'; import CoreLibrariesSection from './CoreLibrariesSection'; import AppLibrariesSection from './AppLibrariesSection'; diff --git a/src/common/icons/index.ts b/src/icons/index.ts similarity index 100% rename from src/common/icons/index.ts rename to src/icons/index.ts diff --git a/src/common/icons/iota/index.ts b/src/icons/iota/index.ts similarity index 100% rename from src/common/icons/iota/index.ts rename to src/icons/iota/index.ts diff --git a/src/common/icons/socials/index.ts b/src/icons/socials/index.ts similarity index 100% rename from src/common/icons/socials/index.ts rename to src/icons/socials/index.ts diff --git a/src/switcher.config.ts b/src/switcher.config.ts index be452ab186a..c8fc86166ea 100644 --- a/src/switcher.config.ts +++ b/src/switcher.config.ts @@ -10,7 +10,7 @@ import { Stronghold, Tools, Wallet, -} from './common/icons'; +} from '@site/src/icons'; const buildDocs = [ { diff --git a/src/utils/socials.ts b/src/utils/socials.ts index 72ab0fb0ef7..17bc789bd19 100644 --- a/src/utils/socials.ts +++ b/src/utils/socials.ts @@ -8,7 +8,7 @@ import { LinkedIn, Instagram, Facebook, -} from '../common/icons'; +} from '@site/src/icons'; const map: Array<{ name: string; From 1a489bc378252d380b789f3833832d1b90679af5 Mon Sep 17 00:00:00 2001 From: Jeroen van den Hout Date: Thu, 14 Sep 2023 16:08:31 +0200 Subject: [PATCH 3/5] Fix cli script --- cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/package.json b/cli/package.json index 56ef0272fac..8f6ed040eaa 100644 --- a/cli/package.json +++ b/cli/package.json @@ -15,7 +15,7 @@ "clean": "rm -rf ./dist", "build": "npx tsc --build && tsc-alias && yarn copy", "copy:internal": "copyfiles \"src/**/!(*.ts|*.js|*.tsx)\" dist/cli", - "copy:external": "copyfiles \"../src/common/css/**/!(*.ts|*.js|*.tsx)\" \"../src/common/icons/**/!(*.ts|*.js|*.tsx)\" \"../src/next/css/**/!(*.ts|*.js|*.tsx)\" dist/cli", + "copy:external": "copyfiles \"../src/common/css/**/!(*.ts|*.js|*.tsx)\" \"../src/icons/**/(*.ts|*.js|*.tsx)\" \"../static/icons/**/!(*.ts|*.js|*.tsx)\" \"../src/next/css/**/!(*.ts|*.js|*.tsx)\" dist/cli", "copy": "yarn copy:internal && yarn copy:external", "watch": "nodemon --watch src --ext '*' --exec yarn build", "prepack": "yarn build" From 8e56ac85eed91dd5c9cf82a97407adb0fb3e9eca Mon Sep 17 00:00:00 2001 From: Jeroen van den Hout Date: Thu, 14 Sep 2023 23:48:12 +0200 Subject: [PATCH 4/5] Export icons as object so they can be dynamically referenced --- .../CustomNetworkDropdown/index.tsx | 4 +- src/common/components/Social/index.tsx | 1 + src/common/components/Switcher/index.tsx | 13 ++-- .../HomeLayout/AppLibrariesSection.tsx | 4 +- .../HomeLayout/CoreLibrariesSection.tsx | 4 +- src/components/HomeLayout/index.tsx | 10 +-- src/icons/index.ts | 9 ++- src/icons/iota/index.ts | 69 +++++++++++++------ src/icons/socials/index.ts | 27 +++++--- src/switcher.config.ts | 40 ++++------- src/utils/socials.ts | 45 +++++------- 11 files changed, 129 insertions(+), 97 deletions(-) diff --git a/src/common/components/CustomNetworkDropdown/index.tsx b/src/common/components/CustomNetworkDropdown/index.tsx index 0883d87b3ff..f4e10d70c6e 100644 --- a/src/common/components/CustomNetworkDropdown/index.tsx +++ b/src/common/components/CustomNetworkDropdown/index.tsx @@ -12,12 +12,14 @@ import type { } from '@theme/NavbarItem/DropdownNavbarItem'; import './styles.css'; -import { IotaCore, Shimmer, Next } from '@site/src/icons'; +import icons from '@site/src/icons'; import { fetchSitemapUrlsFromNetwork, getBestNetworkUrlMatch, } from '@site/src/utils/networkUtils'; +const { IotaCore, Shimmer, Next } = icons; + interface NetworkDropdownItem { label: string; routeBasePath: string; diff --git a/src/common/components/Social/index.tsx b/src/common/components/Social/index.tsx index 1837a0a89d9..49c1f41d440 100644 --- a/src/common/components/Social/index.tsx +++ b/src/common/components/Social/index.tsx @@ -15,6 +15,7 @@ export interface SocialsConfig extends ThemeConfig { function SocialLink({ url, backgroundColor }: Social) { const { name, Icon } = get_socials_data(url); + console.log(name, Icon); return ( >; + icon?: string; }; export type Version = Item; @@ -52,6 +52,11 @@ enum SwitcherMenuState { Versions, } +function Icon({ icon, className }: { icon: string; className: string }) { + const Comp = icons[icon]; + return ; +} + type SwitcherMenuDropdownProps = { items: MenuItem[]; active: boolean }; function SwitcherMenuDropdown(props: SwitcherMenuDropdownProps) { @@ -64,7 +69,7 @@ function SwitcherMenuDropdown(props: SwitcherMenuDropdownProps) { >
    {props.items.map( - ({ id, label, to, active, icon: Icon, description, badges = [] }) => ( + ({ id, label, to, active, icon, description, badges = [] }) => (
  • - {Icon && } + {icon && }
    {label} diff --git a/src/components/HomeLayout/AppLibrariesSection.tsx b/src/components/HomeLayout/AppLibrariesSection.tsx index 9ba8ed253e9..f0d59962e58 100644 --- a/src/components/HomeLayout/AppLibrariesSection.tsx +++ b/src/components/HomeLayout/AppLibrariesSection.tsx @@ -1,6 +1,8 @@ import React, { FC } from 'react'; import Link from '@docusaurus/Link'; -import { Identity, SmartContracts, Streams, Stronghold } from '@site/src/icons'; +import icons from '@site/src/icons'; + +const { Identity, SmartContracts, Streams, Stronghold } = icons; interface LanguagesProps { languages?: { [key: string]: string }; diff --git a/src/components/HomeLayout/CoreLibrariesSection.tsx b/src/components/HomeLayout/CoreLibrariesSection.tsx index 674e5bcd97b..a14912c4528 100644 --- a/src/components/HomeLayout/CoreLibrariesSection.tsx +++ b/src/components/HomeLayout/CoreLibrariesSection.tsx @@ -3,7 +3,9 @@ import CoreLibImgDark from '@site/static/img/homepage/section_core_libraries_dar import ThemedImage from '@theme/ThemedImage'; import React, { FC } from 'react'; import Link from '@docusaurus/Link'; -import { Shimmer } from '@site/src/icons'; +import icons from '@site/src/icons'; + +const { Shimmer } = icons; interface LanguagesProps { languages?: { [key: string]: string }; diff --git a/src/components/HomeLayout/index.tsx b/src/components/HomeLayout/index.tsx index 75204767767..b42138e0398 100644 --- a/src/components/HomeLayout/index.tsx +++ b/src/components/HomeLayout/index.tsx @@ -7,7 +7,11 @@ import Link from '@docusaurus/Link'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import clsx from 'clsx'; import './styles.css'; -import { +import icons from '@site/src/icons'; +import CoreLibrariesSection from './CoreLibrariesSection'; +import AppLibrariesSection from './AppLibrariesSection'; + +const { Chronicle, Discord, Hornet, @@ -19,9 +23,7 @@ import { Tips, Tutorials, Wasp, -} from '@site/src/icons'; -import CoreLibrariesSection from './CoreLibrariesSection'; -import AppLibrariesSection from './AppLibrariesSection'; +} = icons; interface HomepageSectionProps { header?: string; diff --git a/src/icons/index.ts b/src/icons/index.ts index 41a717d63a9..6a987f3cab4 100644 --- a/src/icons/index.ts +++ b/src/icons/index.ts @@ -1,2 +1,7 @@ -export * from './iota'; -export * from './socials'; +import iota from './iota'; +import socials from './socials'; + +export default { + ...iota, + ...socials, +}; diff --git a/src/icons/iota/index.ts b/src/icons/iota/index.ts index 22c0d138461..a293356ca85 100644 --- a/src/icons/iota/index.ts +++ b/src/icons/iota/index.ts @@ -1,22 +1,47 @@ -export { default as Chronicle } from '@site/static/icons/iota/chronicle.svg'; -export { default as Chrysalis } from '@site/static/icons/iota/chrysalis.svg'; -export { default as GettingStarted } from '@site/static/icons/iota/getting_started.svg'; -export { default as GoShimmer } from '@site/static/icons/iota/go_shimmer.svg'; -export { default as Hornet } from '@site/static/icons/iota/hornet.svg'; -export { default as Identity } from '@site/static/icons/iota/identity.svg'; -export { default as IntegrationServices } from '@site/static/icons/iota/integration_services.svg'; -export { default as Iota20 } from '@site/static/icons/iota/iota_20.svg'; -export { default as IotaCore } from '@site/static/icons/iota/iota_core.svg'; -export { default as IotaToken } from '@site/static/icons/iota/iota_token.svg'; -export { default as Next } from '@site/static/icons/iota/next.svg'; -export { default as PickAWallet } from '@site/static/icons/iota/pick_a_wallet.svg'; -export { default as Search } from '@site/static/icons/iota/search.svg'; -export { default as Shimmer } from '@site/static/icons/iota/shimmer.svg'; -export { default as SmartContracts } from '@site/static/icons/iota/smart_contracts.svg'; -export { default as Streams } from '@site/static/icons/iota/streams.svg'; -export { default as Stronghold } from '@site/static/icons/iota/stronghold.svg'; -export { default as Tips } from '@site/static/icons/iota/tips.svg'; -export { default as Tools } from '@site/static/icons/iota/tools.svg'; -export { default as Tutorials } from '@site/static/icons/iota/tutorials.svg'; -export { default as Wallet } from '@site/static/icons/iota/wallet.svg'; -export { default as Wasp } from '@site/static/icons/iota/wasp.svg'; +import { default as Chronicle } from '@site/static/icons/iota/chronicle.svg'; +import { default as Chrysalis } from '@site/static/icons/iota/chrysalis.svg'; +import { default as GettingStarted } from '@site/static/icons/iota/getting_started.svg'; +import { default as GoShimmer } from '@site/static/icons/iota/go_shimmer.svg'; +import { default as Hornet } from '@site/static/icons/iota/hornet.svg'; +import { default as Identity } from '@site/static/icons/iota/identity.svg'; +import { default as IntegrationServices } from '@site/static/icons/iota/integration_services.svg'; +import { default as Iota20 } from '@site/static/icons/iota/iota_20.svg'; +import { default as IotaCore } from '@site/static/icons/iota/iota_core.svg'; +import { default as IotaToken } from '@site/static/icons/iota/iota_token.svg'; +import { default as Next } from '@site/static/icons/iota/next.svg'; +import { default as PickAWallet } from '@site/static/icons/iota/pick_a_wallet.svg'; +import { default as Search } from '@site/static/icons/iota/search.svg'; +import { default as Shimmer } from '@site/static/icons/iota/shimmer.svg'; +import { default as SmartContracts } from '@site/static/icons/iota/smart_contracts.svg'; +import { default as Streams } from '@site/static/icons/iota/streams.svg'; +import { default as Stronghold } from '@site/static/icons/iota/stronghold.svg'; +import { default as Tips } from '@site/static/icons/iota/tips.svg'; +import { default as Tools } from '@site/static/icons/iota/tools.svg'; +import { default as Tutorials } from '@site/static/icons/iota/tutorials.svg'; +import { default as Wallet } from '@site/static/icons/iota/wallet.svg'; +import { default as Wasp } from '@site/static/icons/iota/wasp.svg'; + +export default { + Chronicle, + Chrysalis, + GettingStarted, + GoShimmer, + Hornet, + Identity, + IntegrationServices, + Iota20, + IotaCore, + IotaToken, + Next, + PickAWallet, + Search, + Shimmer, + SmartContracts, + Streams, + Stronghold, + Tips, + Tools, + Tutorials, + Wallet, + Wasp, +}; diff --git a/src/icons/socials/index.ts b/src/icons/socials/index.ts index d451c56e24e..4efce74e544 100644 --- a/src/icons/socials/index.ts +++ b/src/icons/socials/index.ts @@ -1,8 +1,19 @@ -export { default as Discord } from '@site/static/icons/socials/discord.svg'; -export { default as Facebook } from '@site/static/icons/socials/facebook.svg'; -export { default as Github } from '@site/static/icons/socials/github.svg'; -export { default as Instagram } from '@site/static/icons/socials/instagram.svg'; -export { default as LinkedIn } from '@site/static/icons/socials/linkedin.svg'; -export { default as Reddit } from '@site/static/icons/socials/reddit.svg'; -export { default as Twitter } from '@site/static/icons/socials/twitter.svg'; -export { default as Youtube } from '@site/static/icons/socials/youtube.svg'; +import { default as Discord } from '@site/static/icons/socials/discord.svg'; +import { default as Facebook } from '@site/static/icons/socials/facebook.svg'; +import { default as Github } from '@site/static/icons/socials/github.svg'; +import { default as Instagram } from '@site/static/icons/socials/instagram.svg'; +import { default as LinkedIn } from '@site/static/icons/socials/linkedin.svg'; +import { default as Reddit } from '@site/static/icons/socials/reddit.svg'; +import { default as Twitter } from '@site/static/icons/socials/twitter.svg'; +import { default as Youtube } from '@site/static/icons/socials/youtube.svg'; + +export default { + Discord, + Facebook, + Github, + Instagram, + LinkedIn, + Reddit, + Twitter, + Youtube, +}; diff --git a/src/switcher.config.ts b/src/switcher.config.ts index c8fc86166ea..dae9567fefe 100644 --- a/src/switcher.config.ts +++ b/src/switcher.config.ts @@ -1,23 +1,11 @@ import type { Config } from './common/components/Switcher'; -import { - Chronicle, - GoShimmer, - Hornet, - Identity, - IotaCore, - SmartContracts, - Streams, - Stronghold, - Tools, - Wallet, -} from '@site/src/icons'; const buildDocs = [ { id: 'iota-sdk-1-0-0', label: 'IOTA SDK', description: 'Seamlessly integrate IOTA into your app.', - icon: IotaCore, + icon: 'IotaCore', subsection: 'build-layer-1', versions: [ { @@ -31,7 +19,7 @@ const buildDocs = [ id: 'identity-rs-0-5', label: 'Identity', description: 'Trustless digital identity management.', - icon: Identity, + icon: 'Identity', subsection: 'build-layer-1', versions: [ { @@ -60,7 +48,7 @@ const buildDocs = [ id: 'stronghold-rs', label: 'Stronghold', description: 'Securely store secrets.', - icon: Stronghold, + icon: 'Stronghold', subsection: 'build-layer-1', versions: [ { @@ -74,7 +62,7 @@ const buildDocs = [ id: 'cli-wallet', label: 'CLI Wallet', description: 'Command line wallet.', - icon: Wallet, + icon: 'Wallet', subsection: 'build-layer-1', versions: [ { @@ -88,7 +76,7 @@ const buildDocs = [ id: 'apis', label: 'APIs', description: 'All available APIs.', - icon: Tools, + icon: 'Tools', subsection: 'build-layer-1', versions: [ { @@ -100,7 +88,7 @@ const buildDocs = [ id: 'iota-rs-1-4-0', label: 'iota.rs (deprecated)', description: 'Legacy client SDK.', - icon: IotaCore, + icon: 'IotaCore', subsection: 'build-layer-1', versions: [ { @@ -119,7 +107,7 @@ const buildDocs = [ id: 'iotajs', label: 'iota.js (deprecated)', description: 'Legacy JavaScript SDK.', - icon: IotaCore, + icon: 'IotaCore', subsection: 'build-layer-1', versions: [ { @@ -133,7 +121,7 @@ const buildDocs = [ id: 'wallet-rs-0-1-0', label: 'wallet.rs (deprecated)', description: 'Legacy wallet SDK.', - icon: Wallet, + icon: 'Wallet', subsection: 'build-layer-1', versions: [ { @@ -152,7 +140,7 @@ const buildDocs = [ id: 'iota-streams', label: 'Streams (deprecated)', description: 'Secure data channels over the Tangle.', - icon: Streams, + icon: 'Streams', subsection: 'build-layer-1', versions: [ { @@ -166,7 +154,7 @@ const buildDocs = [ id: 'smart-contract-0-7-0', label: 'Smart Contracts', description: 'Create smart contracts.', - icon: SmartContracts, + icon: 'SmartContracts', subsection: 'build-layer-2', versions: [ { @@ -183,7 +171,7 @@ const maintainDocs = [ id: 'hornet-1-2-4', label: 'Hornet', description: 'The primary node software for IOTA.', - icon: Hornet, + icon: 'Hornet', subsection: 'maintain-layer-1', versions: [ { @@ -202,7 +190,7 @@ const maintainDocs = [ id: 'wasp-0-7-0', label: 'Wasp', description: 'The node software to run an ISC network', - icon: SmartContracts, + icon: 'SmartContracts', subsection: 'maintain-layer-2', versions: [ { @@ -216,7 +204,7 @@ const maintainDocs = [ id: 'chronicle-rs', label: 'Chronicle', description: 'Indexer, archival node, analytics.', - icon: Chronicle, + icon: 'Chronicle', subsection: 'maintain-layer-1', versions: [ { @@ -235,7 +223,7 @@ const maintainDocs = [ id: 'goshimmer', label: 'GoShimmer', description: 'Research node implementation for IOTA 2.0', - icon: GoShimmer, + icon: 'GoShimmer', subsection: 'maintain-layer-1', versions: [ { diff --git a/src/utils/socials.ts b/src/utils/socials.ts index 17bc789bd19..1222e7955d6 100644 --- a/src/utils/socials.ts +++ b/src/utils/socials.ts @@ -1,36 +1,25 @@ import { ComponentType, SVGProps } from 'react'; -import { - Youtube, - Github, - Discord, - Twitter, - Reddit, - LinkedIn, - Instagram, - Facebook, -} from '@site/src/icons'; +import icons from '@site/src/icons'; -const map: Array<{ - name: string; - Icon: ComponentType>; -}> = [ - { name: 'Youtube', Icon: Youtube }, - { name: 'GitHub', Icon: Github }, - { name: 'Discord', Icon: Discord }, - { name: 'Twitter', Icon: Twitter }, - { name: 'Reddit', Icon: Reddit }, - { name: 'LinkedIn', Icon: LinkedIn }, - { name: 'Instagram', Icon: Instagram }, - { name: 'Facebook', Icon: Facebook }, +const socials = [ + 'Discord', + 'Facebook', + 'Github', + 'Instagram', + 'LinkedIn', + 'Reddit', + 'Twitter', + 'Youtube', ]; // Returns an object with icon and name for given url -export default function get_socials_data(url: string): (typeof map)[number] { - for (let i = 0; i < map.length; i++) { - if (url.toLowerCase().includes(map[i].name.toLowerCase())) { - return map[i]; +export default function get_socials_data(url: string): { + name: string; + Icon: ComponentType>; +} { + for (const social of socials) { + if (url.toLowerCase().includes(social.toLowerCase())) { + return { name: social, Icon: icons[social] }; } } - - return null; } From d18c44916f5358a7ddb6abab47b5ca861434e690 Mon Sep 17 00:00:00 2001 From: Jeroen van den Hout Date: Fri, 15 Sep 2023 00:01:31 +0200 Subject: [PATCH 5/5] Remove console.log --- src/common/components/Social/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/components/Social/index.tsx b/src/common/components/Social/index.tsx index 49c1f41d440..1c508633249 100644 --- a/src/common/components/Social/index.tsx +++ b/src/common/components/Social/index.tsx @@ -15,7 +15,7 @@ export interface SocialsConfig extends ThemeConfig { function SocialLink({ url, backgroundColor }: Social) { const { name, Icon } = get_socials_data(url); - console.log(name, Icon); + return (