refract-ui 0.0.0 → 1.0.2
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/README.md +14 -3
- package/dist/RefractProvider-Bzz4G22S.cjs +25 -0
- package/dist/RefractProvider-Bzz4G22S.cjs.map +1 -0
- package/dist/RefractProvider-D__A8gQl.js +238 -0
- package/dist/RefractProvider-D__A8gQl.js.map +1 -0
- package/dist/assets/iphone-11.glb +0 -0
- package/dist/assets/macbook-pro.glb +0 -0
- package/dist/carousel.cjs +48 -1
- package/dist/carousel.cjs.map +1 -1
- package/dist/carousel.js +300 -0
- package/dist/carousel.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +10 -0
- package/dist/components/Breadcrumbs/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +22 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Carousel/Carousel.d.ts +21 -0
- package/dist/components/Carousel/index.d.ts +1 -0
- package/dist/components/Divider/Divider.d.ts +12 -0
- package/dist/components/Divider/index.d.ts +2 -0
- package/dist/components/Heading/Heading.d.ts +9 -0
- package/dist/components/Heading/index.d.ts +2 -0
- package/dist/components/Icon/Icon.d.ts +30 -0
- package/dist/components/Icon/index.d.ts +2 -0
- package/dist/components/Image/Image.d.ts +27 -0
- package/dist/components/Image/index.d.ts +1 -0
- package/dist/components/Input/Input.d.ts +21 -0
- package/dist/components/Input/TextArea.d.ts +11 -0
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Link/Link.d.ts +10 -0
- package/dist/components/Link/index.d.ts +1 -0
- package/dist/components/LinkProvider/LinkProvider.d.ts +11 -0
- package/dist/components/LinkProvider/index.d.ts +1 -0
- package/dist/components/List/List.d.ts +11 -0
- package/dist/components/List/index.d.ts +1 -0
- package/dist/components/Loader/Loader.d.ts +6 -0
- package/dist/components/Loader/index.d.ts +2 -0
- package/dist/components/Model/Model.d.ts +40 -0
- package/dist/components/Model/deviceModels.d.ts +29 -0
- package/dist/components/Model/index.d.ts +2 -0
- package/dist/components/RefractProvider/RefractProvider.d.ts +20 -0
- package/dist/components/RefractProvider/index.d.ts +1 -0
- package/dist/components/ScrambleReveal/ScrambleReveal.d.ts +9 -0
- package/dist/components/ScrambleReveal/index.d.ts +1 -0
- package/dist/components/Section/Section.d.ts +8 -0
- package/dist/components/Section/index.d.ts +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +15 -0
- package/dist/components/SegmentedControl/index.d.ts +1 -0
- package/dist/components/Table/Table.d.ts +11 -0
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +21 -0
- package/dist/components/ThemeProvider/index.d.ts +5 -0
- package/dist/components/ThemeProvider/theme.d.ts +138 -0
- package/dist/components/ThemeProvider/useTheme.d.ts +2 -0
- package/dist/components/Transition/Transition.d.ts +19 -0
- package/dist/components/Transition/index.d.ts +1 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +10 -0
- package/dist/components/VisuallyHidden/index.d.ts +2 -0
- package/dist/components/Wordmark/Wordmark.d.ts +5 -0
- package/dist/components/Wordmark/index.d.ts +2 -0
- package/dist/entries/carousel.d.ts +1 -1
- package/dist/entries/model.d.ts +1 -1
- package/dist/hooks/useFormInput.d.ts +11 -0
- package/dist/hooks/useFps.d.ts +8 -0
- package/dist/hooks/useHasMounted.d.ts +1 -0
- package/dist/hooks/useInViewport.d.ts +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -0
- package/dist/index.js +914 -45
- package/dist/index.js.map +1 -1
- package/dist/model.cjs +4 -1
- package/dist/model.cjs.map +1 -1
- package/dist/model.js +267 -0
- package/dist/model.js.map +1 -1
- package/dist/style-CWBkJEps.cjs +2 -0
- package/dist/style-CWBkJEps.cjs.map +1 -0
- package/dist/style-uMN7vipQ.js +96 -0
- package/dist/style-uMN7vipQ.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/three-CWsiEOQZ.js +48 -0
- package/dist/three-CWsiEOQZ.js.map +1 -0
- package/dist/three-aeLbW1yA.cjs +2 -0
- package/dist/three-aeLbW1yA.cjs.map +1 -0
- package/dist/tokens.css +1 -0
- package/dist/utils/delay.d.ts +1 -0
- package/dist/utils/image.d.ts +31 -0
- package/dist/utils/three.d.ts +29 -0
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"three-aeLbW1yA.cjs","sources":["../src/utils/three.ts"],"sourcesContent":["import {\n Cache,\n TextureLoader,\n Mesh,\n Material,\n Object3D,\n Light,\n WebGLRenderer,\n Scene,\n} from 'three';\nimport { DRACOLoader, GLTFLoader } from 'three-stdlib';\n\n// Enable caching for all loaders\nCache.enabled = true;\n\nconst gltfLoaders = new Map<string, GLTFLoader>();\n\n/**\n * GLTF model loader configured with the draco decoder. Constructed lazily on\n * first use rather than at module scope, so importing this module has no\n * side effect. Cached per decoder path.\n */\nexport function getModelLoader(decoderPath = '/draco/'): GLTFLoader {\n let gltfLoader = gltfLoaders.get(decoderPath);\n\n if (!gltfLoader) {\n const dracoLoader = new DRACOLoader();\n dracoLoader.setDecoderPath(decoderPath);\n gltfLoader = new GLTFLoader();\n gltfLoader.setDRACOLoader(dracoLoader);\n gltfLoaders.set(decoderPath, gltfLoader);\n }\n\n return gltfLoader;\n}\n\nexport const textureLoader: TextureLoader = new TextureLoader();\n\n/**\n * Clean up a scene's materials and geometry\n */\nexport const cleanScene = (scene: Scene): void => {\n scene?.traverse(object => {\n if (!(object instanceof Mesh)) return;\n\n object.geometry.dispose();\n\n if (Array.isArray(object.material)) {\n for (const material of object.material) {\n cleanMaterial(material);\n }\n } else {\n cleanMaterial(object.material);\n }\n });\n};\n\n/**\n * Clean up and dispose of a material\n */\nexport const cleanMaterial = (material: Material): void => {\n material.dispose();\n\n const record = material as unknown as Record<string, unknown>;\n\n for (const key of Object.keys(record)) {\n const value = record[key];\n if (\n value &&\n typeof value === 'object' &&\n 'minFilter' in (value as Record<string, unknown>)\n ) {\n const texture = value as { dispose: () => void; source?: { data?: { close?: () => void } } };\n texture.dispose();\n\n // Close GLTF bitmap textures\n texture.source?.data?.close?.();\n }\n }\n};\n\n/**\n * Clean up and dispose of a renderer\n */\nexport const cleanRenderer = (renderer: WebGLRenderer): void => {\n renderer.dispose();\n};\n\n/**\n * Clean up lights by removing them from their parent\n */\nexport const removeLights = (lights: Light[]): void => {\n for (const light of lights) {\n light.parent?.remove(light);\n }\n};\n\n/**\n * Get child by name\n */\nexport const getChild = (name: string, object: Object3D): Object3D | undefined => {\n let node: Object3D | undefined;\n\n object.traverse(child => {\n if (child.name === name) {\n node = child;\n }\n });\n\n return node;\n};\n"],"names":["Cache","gltfLoaders","getModelLoader","decoderPath","gltfLoader","dracoLoader","DRACOLoader","GLTFLoader","textureLoader","TextureLoader","cleanScene","scene","object","Mesh","material","cleanMaterial","record","key","value","texture","_c","_b","_a","cleanRenderer","renderer","removeLights","lights","light"],"mappings":"6EAaAA,EAAAA,MAAM,QAAU,GAEhB,MAAMC,MAAkB,IAOjB,SAASC,EAAeC,EAAc,UAAuB,CAClE,IAAIC,EAAaH,EAAY,IAAIE,CAAW,EAE5C,GAAI,CAACC,EAAY,CACf,MAAMC,EAAc,IAAIC,cACxBD,EAAY,eAAeF,CAAW,EACtCC,EAAa,IAAIG,EAAAA,WACjBH,EAAW,eAAeC,CAAW,EACrCJ,EAAY,IAAIE,EAAaC,CAAU,CACzC,CAEA,OAAOA,CACT,CAEO,MAAMI,EAA+B,IAAIC,EAAAA,cAKnCC,EAAcC,GAAuB,CAChDA,GAAA,MAAAA,EAAO,SAASC,GAAU,CACxB,GAAMA,aAAkBC,EAAAA,KAIxB,GAFAD,EAAO,SAAS,QAAA,EAEZ,MAAM,QAAQA,EAAO,QAAQ,EAC/B,UAAWE,KAAYF,EAAO,SAC5BG,EAAcD,CAAQ,OAGxBC,EAAcH,EAAO,QAAQ,CAEjC,EACF,EAKaG,EAAiBD,GAA6B,WACzDA,EAAS,QAAA,EAET,MAAME,EAASF,EAEf,UAAWG,KAAO,OAAO,KAAKD,CAAM,EAAG,CACrC,MAAME,EAAQF,EAAOC,CAAG,EACxB,GACEC,GACA,OAAOA,GAAU,UACjB,cAAgBA,EAChB,CACA,MAAMC,EAAUD,EAChBC,EAAQ,QAAA,GAGRC,GAAAC,GAAAC,EAAAH,EAAQ,SAAR,YAAAG,EAAgB,OAAhB,YAAAD,EAAsB,QAAtB,MAAAD,EAAA,KAAAC,EACF,CACF,CACF,EAKaE,EAAiBC,GAAkC,CAC9DA,EAAS,QAAA,CACX,EAKaC,EAAgBC,GAA0B,OACrD,UAAWC,KAASD,GAClBJ,EAAAK,EAAM,SAAN,MAAAL,EAAc,OAAOK,EAEzB"}
|
package/dist/tokens.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root { --rgbBlack: 0 0 0; --rgbWhite: 255 255 255; --bezierFastoutSlowin: cubic-bezier(0.4, 0.0, 0.2, 1); --durationXS: 200ms; --durationS: 300ms; --durationM: 400ms; --durationL: 600ms; --durationXL: 800ms; --systemFontStack: system-ui, -apple-system, BlinkMacSystemFont, San Francisco, Roboto, Segoe UI, Ubuntu, Helvetica Neue, sans-serif; --fontStack: var(--brandFontStack, var(--systemFontStack)); --monoFontStack: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace; --devanagariFontStack: Kohinoor Devanagari, Devanagari Sangam MN, Nirmala UI, Noto Sans Devanagari, sans-serif; --fontWeightRegular: 400; --fontWeightMedium: 500; --fontWeightBold: 700; --fontSizeH0: 8.75rem; --fontSizeH1: 6.25rem; --fontSizeH2: 3.625rem; --fontSizeH3: 2.375rem; --fontSizeH4: 1.75rem; --fontSizeH5: 1.5rem; --fontSizeBodyXL: 1.375rem; --fontSizeBodyL: 1.25rem; --fontSizeBodyM: 1.125rem; --fontSizeBodyS: 1rem; --fontSizeBodyXS: 0.875rem; --lineHeightTitle: 1.1; --lineHeightBody: 1.6; --maxWidthS: 540px; --maxWidthM: 720px; --maxWidthL: 1096px; --maxWidthXL: 1680px; --spaceOuter: 64px; --spaceXS: 4px; --spaceS: 8px; --spaceM: 16px; --spaceL: 24px; --spaceXL: 32px; --space2XL: 48px; --space3XL: 64px; --space4XL: 96px; --space5XL: 128px; --zIndex0: 0; --zIndex1: 4; --zIndex2: 8; --zIndex3: 16; --zIndex4: 32; --zIndex5: 64; } @media (max-width: 2080px) { :root { --fontSizeH0: 7.5rem; --fontSizeH1: 5rem; } } @media (max-width: 1680px) { :root { --maxWidthS: 480px; --maxWidthM: 640px; --maxWidthL: 1000px; --maxWidthXL: 1100px; --spaceOuter: 48px; --fontSizeH0: 6.25rem; --fontSizeH1: 4.375rem; --fontSizeH2: 3.125rem; --fontSizeH3: 2.25rem; --fontSizeH4: 1.625rem; --fontSizeH5: 1.375rem; } } @media (max-width: 1040px) { :root { --fontSizeH0: 5rem; --fontSizeH1: 3.75rem; --fontSizeH2: 3rem; --fontSizeH3: 2rem; --fontSizeH4: 1.5rem; --fontSizeH5: 1.25rem; } } @media (max-width: 696px) { :root { --spaceOuter: 24px; --fontSizeH0: 3.5rem; --fontSizeH1: 2.5rem; --fontSizeH2: 2.125rem; --fontSizeH3: 1.75rem; --fontSizeH4: 1.375rem; --fontSizeH5: 1.125rem; --fontSizeBodyL: 1.0625rem; --fontSizeBodyM: 1rem; --fontSizeBodyS: 0.875rem; } } @media (max-width: 400px) { :root { --spaceOuter: 16px; --fontSizeH0: 2.625rem; --fontSizeH1: 2.375rem; --fontSizeH2: 1.75rem; --fontSizeH3: 1.5rem; --fontSizeH4: 1.25rem; } } [data-theme='dark'] { --rgbBackground: 17 17 17; --rgbBackgroundLight: 26 26 26; --rgbPrimary: 251 146 60; --rgbAccent: 251 146 60; --rgbText: 255 255 255; --rgbError: 255 55 102; --colorTextName: 246 240 228; --colorTextTitle: rgb(var(--rgbText) / 1); --colorTextBody: rgb(var(--rgbText) / 0.8); --colorTextLight: rgb(var(--rgbText) / 0.6); } [data-theme='light'] { --rgbBackground: 242 242 242; --rgbBackgroundLight: 255 255 255; --rgbPrimary: 168 85 8; --rgbAccent: 255 138 45; --rgbText: 0 0 0; --rgbError: 255 0 60; --colorTextName: 28 24 20; --colorTextTitle: rgb(var(--rgbText) / 1); --colorTextBody: rgb(var(--rgbText) / 0.8); --colorTextLight: rgb(var(--rgbText) / 0.6); }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function delay(ms: number): Promise<void>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
interface SrcSetItem {
|
|
2
|
+
src: string;
|
|
3
|
+
width: number;
|
|
4
|
+
}
|
|
5
|
+
type SrcSet = string | SrcSetItem[];
|
|
6
|
+
/**
|
|
7
|
+
* Use the browser's image loading to load an image and
|
|
8
|
+
* grab the `src` it chooses from a `srcSet`
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadImageFromSrcSet({ src, srcSet, sizes, }: {
|
|
11
|
+
src?: string;
|
|
12
|
+
srcSet?: SrcSet;
|
|
13
|
+
sizes?: string;
|
|
14
|
+
}): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Convert a `srcSet` array to a plain old `srcSet` string
|
|
17
|
+
*/
|
|
18
|
+
export declare function srcSetToString(srcSet?: SrcSet): string;
|
|
19
|
+
/**
|
|
20
|
+
* Generates a transparent png of a given width and height
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateImage(width?: number, height?: number): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Use native html image `srcSet` resolution for non-html images
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveSrcFromSrcSet({ srcSet, sizes, }: {
|
|
27
|
+
srcSet?: SrcSet;
|
|
28
|
+
sizes?: string;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}): Promise<string>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TextureLoader, Material, Object3D, Light, WebGLRenderer, Scene } from 'three';
|
|
2
|
+
import { GLTFLoader } from 'three-stdlib';
|
|
3
|
+
/**
|
|
4
|
+
* GLTF model loader configured with the draco decoder. Constructed lazily on
|
|
5
|
+
* first use rather than at module scope, so importing this module has no
|
|
6
|
+
* side effect. Cached per decoder path.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getModelLoader(decoderPath?: string): GLTFLoader;
|
|
9
|
+
export declare const textureLoader: TextureLoader;
|
|
10
|
+
/**
|
|
11
|
+
* Clean up a scene's materials and geometry
|
|
12
|
+
*/
|
|
13
|
+
export declare const cleanScene: (scene: Scene) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Clean up and dispose of a material
|
|
16
|
+
*/
|
|
17
|
+
export declare const cleanMaterial: (material: Material) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Clean up and dispose of a renderer
|
|
20
|
+
*/
|
|
21
|
+
export declare const cleanRenderer: (renderer: WebGLRenderer) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Clean up lights by removing them from their parent
|
|
24
|
+
*/
|
|
25
|
+
export declare const removeLights: (lights: Light[]) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Get child by name
|
|
28
|
+
*/
|
|
29
|
+
export declare const getChild: (name: string, object: Object3D) => Object3D | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "refract-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Themeable React component library — primitives, form controls, and Three.js device/carousel components.",
|
|
5
5
|
"homepage": "https://storybook.parammehta.com",
|
|
6
6
|
"repository": "https://github.com/parammehta/refract-ui.git",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"require": "./dist/index.cjs"
|
|
25
25
|
},
|
|
26
26
|
"./model": {
|
|
27
|
-
"types": "./dist/model.d.ts",
|
|
27
|
+
"types": "./dist/entries/model.d.ts",
|
|
28
28
|
"import": "./dist/model.js",
|
|
29
29
|
"require": "./dist/model.cjs"
|
|
30
30
|
},
|
|
31
31
|
"./carousel": {
|
|
32
|
-
"types": "./dist/carousel.d.ts",
|
|
32
|
+
"types": "./dist/entries/carousel.d.ts",
|
|
33
33
|
"import": "./dist/carousel.js",
|
|
34
34
|
"require": "./dist/carousel.cjs"
|
|
35
35
|
},
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@types/three": "^0.185.3",
|
|
69
69
|
"@vitejs/plugin-react": "^4.3.4",
|
|
70
70
|
"eslint": "^9.39.5",
|
|
71
|
-
"eslint-plugin-react-hooks": "^
|
|
71
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
72
72
|
"eslint-plugin-storybook": "^10.5.5",
|
|
73
73
|
"framer-motion": "^7.10.3",
|
|
74
74
|
"fs-extra": "^10.1.0",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"scripts": {
|
|
97
97
|
"dev": "storybook dev -p 9009 -h localhost",
|
|
98
98
|
"storybook": "storybook dev -p 9009 -h localhost",
|
|
99
|
-
"build": "vite build && node scripts/copy-static-css.cjs",
|
|
99
|
+
"build": "vite build && node scripts/copy-static-assets.cjs && node scripts/build-tokens-css.cjs && node scripts/verify-exports.cjs",
|
|
100
100
|
"build:storybook": "storybook build -o build-storybook && node scripts/draco-storybook.cjs && node scripts/models-storybook.cjs",
|
|
101
101
|
"lint": "eslint .",
|
|
102
102
|
"stylelint": "stylelint \"src/**/*.css\"",
|