@liner-fe/prism 2.1.73 → 2.1.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/illust.d.ts +4 -4
- package/lib/illust.js +4 -1
- package/lib/illust.js.map +1 -1
- package/lib/index.css +697 -427
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +105 -6
- package/lib/index.js +8473 -3562
- package/lib/index.js.map +1 -1
- package/package.json +2 -3
package/lib/illust.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface Source<T extends false | true = true> {
|
|
|
10
10
|
name: IllustType;
|
|
11
11
|
inverse?: T;
|
|
12
12
|
}
|
|
13
|
-
interface
|
|
13
|
+
interface IllustProps extends Omit<ImageProps, 'alt' | 'width' | 'height' | 'fill' | 'src'> {
|
|
14
14
|
width: number;
|
|
15
15
|
src: {
|
|
16
16
|
light: Source<false>;
|
|
@@ -18,11 +18,11 @@ interface IProps extends Omit<ImageProps, 'alt' | 'width' | 'height' | 'fill' |
|
|
|
18
18
|
};
|
|
19
19
|
margin?: Property.Margin<string>;
|
|
20
20
|
}
|
|
21
|
-
declare const Illust: (props:
|
|
21
|
+
declare const Illust: (props: IllustProps) => react_jsx_runtime.JSX.Element;
|
|
22
22
|
|
|
23
|
-
declare const prefetchIllust: ({ name, isDark }: {
|
|
23
|
+
declare const prefetchIllust: ({ name, isDark, }: {
|
|
24
24
|
name: IllustType;
|
|
25
25
|
isDark?: boolean;
|
|
26
26
|
}) => Promise<Response>;
|
|
27
27
|
|
|
28
|
-
export { Illust, type Source, prefetchIllust };
|
|
28
|
+
export { Illust, type IllustProps, type Source, prefetchIllust };
|
package/lib/illust.js
CHANGED
|
@@ -117,5 +117,8 @@ var Illust = /* @__PURE__ */ __name((props) => {
|
|
|
117
117
|
}, "Illust");
|
|
118
118
|
|
|
119
119
|
// src/utils/illust.ts
|
|
120
|
-
var prefetchIllust = /* @__PURE__ */ __name(async ({
|
|
120
|
+
var prefetchIllust = /* @__PURE__ */ __name(async ({
|
|
121
|
+
name,
|
|
122
|
+
isDark = false
|
|
123
|
+
}) => await fetch(`${ILLUST}${isDark ? "/dark/" : "/light/"}${name}.webp`), "prefetchIllust");
|
|
121
124
|
//# sourceMappingURL=illust.js.map
|
package/lib/illust.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/illust.ts","../src/constants/illust/size.ts","../src/components/Illust/index.tsx","../src/constants/illust/path.ts","../src/hooks/useIllust.ts","../src/utils/illust.ts"],"sourcesContent":["export * from './components/Illust';\nexport * from './utils/illust';\n","import { IllustType } from '@/types/illust';\n\nconst ratio = { '16:9': { width: 1344, height: 756 }, '4:3': { width: 1008, height: 756 } };\n\nexport const illustSize: Partial<Record<IllustType, { width: number; height: number }>> = {\n 'object-pencil_paper-16_9': ratio['16:9'],\n 'object-smoke-16_9': ratio['16:9'],\n 'person-standing_with_a_star-16_9': ratio['16:9'],\n 'person-searching-16_9': ratio['16:9'],\n 'person-cheerup-16_9': ratio['16:9'],\n 'object-graduation_cap_pencil-4_3': ratio['4:3'],\n 'object-book_pencil-4_3': ratio['4:3'],\n 'object-puzzle-4_3': ratio['4:3'],\n 'object-magnifying_glass-4_3': ratio['4:3'],\n 'object-lock-4_3': ratio['4:3'],\n 'object-empty_box-4_3': ratio['4:3'],\n 'person-working_01-4_3': ratio['4:3'],\n 'person-searching_01-4_3': ratio['4:3'],\n 'person-worried_01-4_3': ratio['4:3'],\n 'person-worried_02-4_3': ratio['4:3'],\n 'person-worried_03-4_3': ratio['4:3'],\n 'person-worried_04-4_3': ratio['4:3'],\n 'person-working_02-4_3': ratio['4:3'],\n 'person-bye-4_3': ratio['4:3'],\n 'person-space_in_work-4_3': ratio['4:3'],\n 'person-cheerup-4_3': ratio['4:3'],\n};\n","import { illustSize } from '@/constants/illust/size';\nimport Image, { ImageProps } from 'next/image';\nimport { CSSProperties } from 'react';\nimport { useIllust } from '@/hooks/useIllust';\nimport { IllustType } from '@/types/illust';\nimport { Property } from 'csstype';\n\nexport interface Source<T extends false | true = true> {\n name: IllustType;\n inverse?: T;\n}\n\
|
|
1
|
+
{"version":3,"sources":["../src/illust.ts","../src/constants/illust/size.ts","../src/components/Illust/index.tsx","../src/constants/illust/path.ts","../src/hooks/useIllust.ts","../src/utils/illust.ts"],"sourcesContent":["export * from './components/Illust';\nexport * from './utils/illust';\n","import { IllustType } from '@/types/illust';\n\nconst ratio = { '16:9': { width: 1344, height: 756 }, '4:3': { width: 1008, height: 756 } };\n\nexport const illustSize: Partial<Record<IllustType, { width: number; height: number }>> = {\n 'object-pencil_paper-16_9': ratio['16:9'],\n 'object-smoke-16_9': ratio['16:9'],\n 'person-standing_with_a_star-16_9': ratio['16:9'],\n 'person-searching-16_9': ratio['16:9'],\n 'person-cheerup-16_9': ratio['16:9'],\n 'object-graduation_cap_pencil-4_3': ratio['4:3'],\n 'object-book_pencil-4_3': ratio['4:3'],\n 'object-puzzle-4_3': ratio['4:3'],\n 'object-magnifying_glass-4_3': ratio['4:3'],\n 'object-lock-4_3': ratio['4:3'],\n 'object-empty_box-4_3': ratio['4:3'],\n 'person-working_01-4_3': ratio['4:3'],\n 'person-searching_01-4_3': ratio['4:3'],\n 'person-worried_01-4_3': ratio['4:3'],\n 'person-worried_02-4_3': ratio['4:3'],\n 'person-worried_03-4_3': ratio['4:3'],\n 'person-worried_04-4_3': ratio['4:3'],\n 'person-working_02-4_3': ratio['4:3'],\n 'person-bye-4_3': ratio['4:3'],\n 'person-space_in_work-4_3': ratio['4:3'],\n 'person-cheerup-4_3': ratio['4:3'],\n};\n","import { illustSize } from '@/constants/illust/size';\nimport Image, { ImageProps } from 'next/image';\nimport { CSSProperties } from 'react';\nimport { useIllust } from '@/hooks/useIllust';\nimport { IllustType } from '@/types/illust';\nimport { Property } from 'csstype';\n\nexport interface Source<T extends false | true = true> {\n name: IllustType;\n inverse?: T;\n}\n\nexport interface IllustProps extends Omit<ImageProps, 'alt' | 'width' | 'height' | 'fill' | 'src'> {\n width: number;\n src: { light: Source<false>; dark?: Source };\n margin?: Property.Margin<string>;\n}\n\nexport const Illust = (props: IllustProps) => {\n const { src, width, margin } = props;\n const { sourcePrefix, currentSourceByColorTheme } = useIllust({\n darkSrc: src.dark,\n src: src.light,\n });\n\n const aspectRatio = illustSize[currentSourceByColorTheme]\n ? illustSize[currentSourceByColorTheme].width / illustSize[currentSourceByColorTheme].height\n : undefined;\n\n const css: CSSProperties = {\n width,\n margin,\n };\n\n const source = `${sourcePrefix}${currentSourceByColorTheme}.webp`;\n\n return (\n <div style={css}>\n <Image\n alt={currentSourceByColorTheme}\n {...props}\n src={source}\n width={width}\n height={aspectRatio ? width / aspectRatio : width}\n />\n </div>\n );\n};\n","export const ILLUST = '/illust';\n\nexport const DARK_MODE_ILLUST_PREFIX = `${ILLUST}/dark/`;\nexport const LIGHT_MODE_ILLUST_PREFIX = `${ILLUST}/light/`;\n","import { Source } from '@/components/Illust';\nimport { DARK_MODE_ILLUST_PREFIX, LIGHT_MODE_ILLUST_PREFIX } from '@/constants/illust/path';\nimport { useDarkTheme } from '@liner-fe/design-token';\n\nexport const useIllust = ({ darkSrc, src }: { darkSrc?: Source; src: Source<false> }) => {\n const { isDarkMode } = useDarkTheme();\n\n const sourcePrefix = (() => {\n if (isDarkMode) {\n if (darkSrc?.inverse) {\n return LIGHT_MODE_ILLUST_PREFIX;\n }\n\n return DARK_MODE_ILLUST_PREFIX;\n }\n\n if (src.inverse === false) {\n return DARK_MODE_ILLUST_PREFIX;\n }\n\n return LIGHT_MODE_ILLUST_PREFIX;\n })();\n\n const currentSourceByColorTheme = isDarkMode ? darkSrc?.name || src.name : src.name;\n\n return { sourcePrefix, currentSourceByColorTheme, isDarkMode };\n};\n","import { ILLUST } from '@/constants/illust/path';\nimport { IllustType } from '@/types/illust';\n\nexport const prefetchIllust = async ({\n name,\n isDark = false,\n}: {\n name: IllustType;\n isDark?: boolean;\n}) => await fetch(`${ILLUST}${isDark ? '/dark/' : '/light/'}${name}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