diff --git a/package.json b/package.json index c29c1b6..d7c50cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "soda-material", - "version": "0.0.26", + "version": "0.0.27", "type": "module", "types": "dist", "main": "dist/index.js", @@ -25,30 +25,30 @@ "@material/material-color-utilities": "^0.2.7", "@mdi/js": "^7.4.47", "@mdi/react": "^1.6.1", - "@storybook/addon-essentials": "^8.0.9", - "@storybook/addon-interactions": "^8.0.9", - "@storybook/addon-links": "^8.0.9", - "@storybook/blocks": "^8.0.9", - "@storybook/react": "^8.0.9", - "@storybook/react-vite": "^8.0.9", + "@storybook/addon-essentials": "^8.0.10", + "@storybook/addon-interactions": "^8.0.10", + "@storybook/addon-links": "^8.0.10", + "@storybook/blocks": "^8.0.10", + "@storybook/react": "^8.0.10", + "@storybook/react-vite": "^8.0.10", "@types/react": "^18.3.1", "@types/react-dom": "^18.3.0", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", "@vitejs/plugin-react": "^4.2.1", - "chromatic": "^11.3.0", + "chromatic": "^11.3.2", "clsx": "^2.1.1", "eslint": "^8.57.0", "eslint-plugin-react-hooks": "^4.6.2", - "eslint-plugin-react-refresh": "^0.4.6", + "eslint-plugin-react-refresh": "^0.4.7", "eslint-plugin-storybook": "^0.8.0", - "glob": "^10.3.12", + "glob": "^10.3.14", "prettier": "^3.2.5", - "sass": "^1.76.0", - "storybook": "^8.0.9", - "styled-jsx": "^5.1.2", + "sass": "^1.77.1", + "storybook": "^8.0.10", + "styled-jsx": "^5.1.3", "typescript": "^5.4.5", - "vite": "^5.2.10" + "vite": "^5.2.11" }, "publishConfig": { "registry": "https://registry.npmjs.org" diff --git a/src/components/tabs/Tabs.tsx b/src/components/tabs/Tabs.tsx index bea3c8d..883c327 100644 --- a/src/components/tabs/Tabs.tsx +++ b/src/components/tabs/Tabs.tsx @@ -1,6 +1,6 @@ import './tabs.scss' import clsx from 'clsx' -import { forwardRef, useEffect, useRef, useState } from 'react' +import { forwardRef, useCallback, useEffect, useRef, useState } from 'react' import { useAutoState } from '@/hooks/use-auto-state' import { useMergeRefs } from '@/hooks/use-merge' import { Ripple } from '@/ripple/Ripple' @@ -59,7 +59,7 @@ export const Tabs = forwardRef< const [left, setLeft] = useState('0') const [width, setWidth] = useState('36px') - useEffect(() => { + const correctlyPlaceIndicator = useCallback(() => { const tabs = ref.current if (!tabs) return const item = tabs.querySelectorAll('.sd-tabs-item')[ @@ -96,6 +96,14 @@ export const Tabs = forwardRef< } }, [index, variant]) + useEffect(correctlyPlaceIndicator, [correctlyPlaceIndicator]) + + useEffect(() => { + window.addEventListener('resize', correctlyPlaceIndicator) + return () => + window.removeEventListener('resize', correctlyPlaceIndicator) + }, [correctlyPlaceIndicator]) + return (
+ +# Dynamic Color + +```ts +// provide some helper function +import { type Theme, themeFromHexString, themeFromImageOrFile } from "soda-material/dist/utils/theme.js" +const theme: Theme = themeFromHexString('#6750a4') +const theme: Theme = await themeFromImageOrFile(/* accept HTMLImageElement or File object */) + +// apply theme +import { applyThemeForSoda } from 'soda-material/dist/utils/theme.js' +applyThemeForSoda('#6750a4') +applyThemeForSoda(theme) +``` + +It's actually a module that provides some helper function and re-export the [@material/material-color-utilities](https://npm.im/@material/material-color-utilities) package. + +# Color Schemes + +Refer to [https://m3.material.io/styles/color/static/baseline](https://m3.material.io/styles/color/static/baseline) + +
+ Manually select a color:
+
+
+ Dynamic color from image:
+
-