morewings / css-vars-hook Goto Github PK
View Code? Open in Web Editor NEWcss-vars-hook contains React hooks to set and manipulate CSS custom properties from the component.
License: MIT License
css-vars-hook contains React hooks to set and manipulate CSS custom properties from the component.
License: MIT License
const theme = {
numeric: {
value: 6,
unit: ‘px’,
}
}
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are awaiting their schedule. Click on a checkbox to get an update now.
@commitlint/cli
, commitlint
)@types/react
, @types/react-dom
)@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
)@semantic-release/commit-analyzer
, @semantic-release/release-notes-generator
).github/workflows/merge-jobs.yml
actions/checkout v4
styfle/cancel-workflow-action 0.12.1
actions/setup-node v4
pnpm/action-setup v2
actions/cache v4
.github/workflows/pages.yml
actions/checkout v4
styfle/cancel-workflow-action 0.12.1
actions/setup-node v4
pnpm/action-setup v3
actions/cache v4
actions/configure-pages v4
actions/upload-pages-artifact v3
actions/deploy-pages v4
.github/workflows/pull-request-jobs.yml
actions/checkout v4
styfle/cancel-workflow-action 0.12.1
actions/setup-node v4
pnpm/action-setup v3
actions/cache v4
package.json
@commitlint/cli 19.2.0
@commitlint/config-conventional 19.1.0
@semantic-release/commit-analyzer 11.1.0
@semantic-release/git 10.0.1
@semantic-release/github 10.0.2
@semantic-release/npm 12.0.0
@semantic-release/release-notes-generator 12.1.0
@testing-library/jest-dom 6.4.2
@testing-library/react 14.2.1
@types/jest 29.5.12
@types/lodash 4.17.0
@types/react 18.2.66
@types/react-dom 18.2.22
@typescript-eslint/eslint-plugin 7.2.0
@typescript-eslint/parser 7.2.0
@vitejs/plugin-react 4.2.1
@yelo/rollup-node-external ^1.0.1
alias-hq 6.2.3
commitizen 4.3.0
commitlint 19.2.0
cz-conventional-changelog 3.3.0
classnames ^2.5.1
eslint 8.57.0
eslint-config-prettier 9.1.0
eslint-plugin-import 2.29.1
eslint-plugin-prettier 5.1.3
eslint-plugin-react 7.34.1
eslint-plugin-react-hooks 4.6.0
eslint-plugin-react-refresh 0.4.6
eslint-plugin-ssr-friendly 1.3.0
eslint-plugin-storybook 0.8.0
husky 9.0.11
identity-obj-proxy 3.0.0
is-ci 3.0.1
jest 29.7.0
jest-environment-jsdom 29.7.0
lint-staged 15.2.2
npm-run-all2 6.1.2
postcss 8.4.35
postcss-preset-env ^9.4.0
prettier 3.2.5
react 18.2.0
react-dom 18.2.0
semantic-release 23.0.4
stylelint 16.2.1
stylelint-config-standard 36.0.0
stylelint-order 6.0.4
stylelint-prettier 5.0.0
ts-jest 29.1.2
ts-node 10.9.2
typescript 5.4.2
vite 5.1.6
vite-plugin-dts ^3.7.3
react >=18.2.0
react-dom >=18.2.0
node >=16
.nvmrc
node v20
Extract to external component to have proper displayName
Theme variables can pollute DOM if injected into style
attribute as it is. <style>
tag may be a cleaner way to store theme. The standard requires <style>
to be injected in the head. Though it works in all browsers and this approach is used in Emotion.
Render <style>
tag inside body on server. Then transport it to the <head>
with createPortal
.
At the moment, demo page uses logic which requires React to rerender components. Needs to be changed to non-rendering techniques.
useEffect
to setVariable
and setTheme
The reason this code isn’t correct is that it tries to do something with the DOM node during rendering. In React, rendering should be a pure calculation of JSX and should not contain side effects like modifying the DOM.
Moreover, when VideoPlayer is called for the first time, its DOM does not exist yet! There isn’t a DOM node yet to call play() or pause() on, because React doesn’t know what DOM to create until you return the JSX.
The solution here is to wrap the side effect with useEffect to move it out of the rendering calculation:
By wrapping the DOM update in an Effect, you let React update the screen first. Then your Effect runs.
When your VideoPlayer component renders (either the first time or if it re-renders), a few things will happen. First, React will update the screen, ensuring the
At current state it rererenders every time
Use function which returns react ref.
css-vars-hook/src/lib/useTheme.js
Line 23 in c21f923
useRootTheme
getVariable
gets token value from local or global scope. Maybe needs to be wrapped in useEffect
useLocalTheme({case, ref})
<Provider case=“camel|kebab” ref={ref}/>
Add missing getCSSRootVariable
and setTheme
to root hook interface. useEfffect
may help with earlier. useState
with later.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.