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

fix!: adjust-icons-import-export #620

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/icon-files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"type": "module",
"main": "./src/index.cjs",
"module": " ./src/index.js",
"exports": {
"require": "./src/index.cjs",
"default": "./src/index.js"
},
"types": "./src/index.d.ts",
"files": [
"src",
Expand Down
8 changes: 3 additions & 5 deletions packages/icons/src/charcoalIconFiles.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import charcoalIconFiles from '@charcoal-ui/icon-files'
import type charcoalIconFiles from '@charcoal-ui/icon-files'

export default charcoalIconFiles

Check failure on line 3 in packages/icons/src/charcoalIconFiles.ts

View workflow job for this annotation

GitHub Actions / test

.storybook/storybook.test.ts

ReferenceError: charcoalIconFiles is not defined ❯ packages/icons/src/charcoalIconFiles.ts:3:16 ❯ packages/icons/src/loaders/index.ts:1:1

Check failure on line 3 in packages/icons/src/charcoalIconFiles.ts

View workflow job for this annotation

GitHub Actions / test

packages/icons/src/PixivIcon.test.tsx

ReferenceError: charcoalIconFiles is not defined ❯ packages/icons/src/charcoalIconFiles.ts:3:16 ❯ packages/icons/src/loaders/index.ts:1:1

Check failure on line 3 in packages/icons/src/charcoalIconFiles.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/components/MultiSelect/index.test.tsx

ReferenceError: charcoalIconFiles is not defined ❯ packages/icons/src/charcoalIconFiles.ts:3:16 ❯ packages/icons/src/loaders/index.ts:1:1
export type KnownIconFile = keyof typeof charcoalIconFiles
export const KNOWN_ICON_FILES = Object.keys(
charcoalIconFiles
) as KnownIconFile[]
export const KNOWN_ICON_FILES: KnownIconFile[] = []

export function isKnownIconFile(name: string): name is KnownIconFile {
return name in charcoalIconFiles
return true
}
9 changes: 7 additions & 2 deletions packages/icons/src/loaders/CharcoalIconFilesLoader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PixivIconLoadError } from './PixivIconLoadError'
import { Loadable } from './Loadable'
import charcoalIconFiles, { KnownIconFile } from '../charcoalIconFiles'
import { KnownIconFile } from '../charcoalIconFiles'

/**
* `@charcoal-ui/icon-files` に収録されているアイコンを取ってくる
Expand All @@ -15,7 +15,12 @@ export class CharcoalIconFilesLoader implements Loadable {
}

get importIconFile() {
return charcoalIconFiles[this._name]
const [size, name] = this._name.split('/')

return () =>
import(`@charcoal-ui/icon-files/src/${size}/${name}.js`).then(
(res: { default: string }) => res.default
)
}

async fetch(): Promise<string> {
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/components/Icon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as React from 'react'

import '@charcoal-ui/icons'
import type { PixivIcon, Props } from '@charcoal-ui/icons'

import '@charcoal-ui/icons'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charcoal-ui/icon-files から import して icon を個別に使うようにする


export interface OwnProps {
unsafeNonGuidelineScale?: number
className?: string
Expand Down
Loading