@hopper-ui/styled-system 0.2.1 → 0.2.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/CHANGELOG.md +6 -0
- package/dist/StyledSystemProvider.css +132 -1
- package/dist/StyledSystemProvider.d.ts +42 -4
- package/dist/StyledSystemProvider.js +25 -26
- package/dist/chunk-2ITAI3PJ.js +270 -0
- package/dist/chunk-35LDZFKX.js +29 -0
- package/dist/chunk-3YM73BQP.js +6 -0
- package/dist/chunk-7HCELIKZ.js +41 -0
- package/dist/chunk-FYKLSVLR.js +39 -0
- package/dist/chunk-GYREQTEK.js +30 -0
- package/dist/chunk-I37Y2R7V.js +4 -0
- package/dist/chunk-IK6W4ZXH.js +11 -0
- package/dist/chunk-IP7TYBR3.js +19 -0
- package/dist/chunk-JBWKRDVA.js +27 -0
- package/dist/chunk-JQBON2KA.js +23 -0
- package/dist/chunk-KUUJ37DW.js +96 -0
- package/dist/chunk-LU33LZMJ.js +55 -0
- package/dist/chunk-OHW5NUAW.js +59 -0
- package/dist/chunk-Q3NLRNZN.js +881 -0
- package/dist/chunk-RIR7BXVF.js +711 -0
- package/dist/chunk-STEDL5VQ.js +25 -0
- package/dist/chunk-U3SI5QXV.js +911 -0
- package/dist/chunk-U5R6ZXH3.js +46 -0
- package/dist/chunk-V7X6ANEM.js +14 -0
- package/dist/chunk-X5OXC6DN.js +9 -0
- package/dist/chunk-XUHDFZZL.js +10 -0
- package/dist/chunk-YPIK2HRL.js +6 -0
- package/dist/chunk-ZO3DYLQJ.js +32 -0
- package/dist/chunk-ZQUJDDQL.js +84 -0
- package/dist/chunk-ZUVKM5DV.js +13 -0
- package/dist/color-scheme/ColorSchemeContext.d.ts +12 -0
- package/dist/color-scheme/ColorSchemeContext.js +1 -0
- package/dist/color-scheme/useColorScheme.d.ts +6 -0
- package/dist/color-scheme/useColorScheme.js +2 -0
- package/dist/color-scheme/useColorSchemeValue.d.ts +3 -0
- package/dist/color-scheme/useColorSchemeValue.js +2 -0
- package/dist/global-styles/BodyStyleProvider.d.ts +5 -0
- package/dist/global-styles/BodyStyleProvider.js +8 -0
- package/dist/html-wrappers/html.css +132 -0
- package/dist/{StyledSystemProvider-173b78af.d.ts → html-wrappers/html.d.ts} +8 -53
- package/dist/html-wrappers/html.js +10 -0
- package/dist/html-wrappers/htmlElement.css +132 -0
- package/dist/html-wrappers/htmlElement.d.ts +12 -0
- package/dist/html-wrappers/htmlElement.js +9 -0
- package/dist/index.css +132 -1
- package/dist/index.d.ts +23 -2385
- package/dist/index.js +26 -26
- package/dist/responsive/BreakpointContext.d.ts +10 -0
- package/dist/responsive/BreakpointContext.js +2 -0
- package/dist/responsive/BreakpointProvider.d.ts +12 -0
- package/dist/responsive/BreakpointProvider.js +5 -0
- package/dist/responsive/Breakpoints.d.ts +10 -0
- package/dist/responsive/Breakpoints.js +1 -0
- package/dist/responsive/useResponsiveValue.d.ts +11 -0
- package/dist/responsive/useResponsiveValue.js +4 -0
- package/dist/styled-system-props.d.ts +1246 -3
- package/dist/styled-system-props.js +1 -3
- package/dist/styled-system-root-css-class.js +1 -3
- package/dist/tokens/TokenProvider.d.ts +20 -0
- package/dist/tokens/TokenProvider.js +8 -0
- package/dist/tokens/generated/dark-semantic-tokens.d.ts +272 -0
- package/dist/tokens/generated/dark-semantic-tokens.js +1 -0
- package/dist/tokens/generated/light-semantic-tokens.d.ts +883 -0
- package/dist/tokens/generated/light-semantic-tokens.js +1 -0
- package/dist/tokens/generated/styled-system-to-token-mappings.d.ts +913 -0
- package/dist/tokens/generated/styled-system-to-token-mappings.js +1 -0
- package/dist/{styled-system-props-1c231c50.d.ts → tokens/token-mappings.d.ts} +2 -1258
- package/dist/tokens/token-mappings.js +6 -0
- package/dist/tokens/tokens.d.ts +1154 -0
- package/dist/tokens/tokens.js +3 -0
- package/dist/useStyledSystem.css +125 -1
- package/dist/useStyledSystem.d.ts +4 -1
- package/dist/useStyledSystem.js +8 -5
- package/dist/utils/assertion.d.ts +15 -0
- package/dist/utils/assertion.js +1 -0
- package/dist/utils/useInsertStyleElement.d.ts +6 -0
- package/dist/utils/useInsertStyleElement.js +3 -0
- package/dist/utils/useIsomorphicInsertionEffect.d.ts +16 -0
- package/dist/utils/useIsomorphicInsertionEffect.js +1 -0
- package/dist/utils/useIsomorphicLayoutEffect.d.ts +16 -0
- package/dist/utils/useIsomorphicLayoutEffect.js +1 -0
- package/dist/utils/useMediaQuery.d.ts +4 -0
- package/dist/utils/useMediaQuery.js +1 -0
- package/dist/utils/useThemeComputedStyle.d.ts +14 -0
- package/dist/utils/useThemeComputedStyle.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BreakpointContext } from './chunk-ZUVKM5DV.js';
|
|
2
|
+
import { Breakpoints } from './chunk-XUHDFZZL.js';
|
|
3
|
+
import { supportsMatchMedia } from './chunk-STEDL5VQ.js';
|
|
4
|
+
import { useCallback, useState, useEffect } from 'react';
|
|
5
|
+
import { useIsSSR } from 'react-aria';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var DefaultUnsupportedMatchMediaBreakpoint = "lg";
|
|
9
|
+
function BreakpointProvider({
|
|
10
|
+
children,
|
|
11
|
+
unsupportedMatchMediaBreakpoint = DefaultUnsupportedMatchMediaBreakpoint
|
|
12
|
+
}) {
|
|
13
|
+
const matchedBreakpoints = useMatchedBreakpoints(unsupportedMatchMediaBreakpoint);
|
|
14
|
+
return /* @__PURE__ */ jsx(BreakpointContext.Provider, { value: { matchedBreakpoints }, children });
|
|
15
|
+
}
|
|
16
|
+
function useMatchedBreakpoints(unsupportedMatchMediaBreakpoint = DefaultUnsupportedMatchMediaBreakpoint) {
|
|
17
|
+
const getBreakpointHandler = useCallback(() => {
|
|
18
|
+
const entries = Object.entries(Breakpoints).sort(([, valueA], [, valueB]) => valueB - valueA);
|
|
19
|
+
const breakpointQueries = entries.map(([, value]) => `(min-width: ${value}px)`);
|
|
20
|
+
const matched = [];
|
|
21
|
+
for (const i in breakpointQueries) {
|
|
22
|
+
const query = breakpointQueries[i];
|
|
23
|
+
if (window.matchMedia(query).matches) {
|
|
24
|
+
matched.push(entries[i][0]);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
matched.push("base");
|
|
28
|
+
return matched;
|
|
29
|
+
}, []);
|
|
30
|
+
const [matchedBreakpoints, setMatchedBreakpoints] = useState(
|
|
31
|
+
supportsMatchMedia ? getBreakpointHandler() : [unsupportedMatchMediaBreakpoint]
|
|
32
|
+
);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!supportsMatchMedia) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const handleResize = () => {
|
|
38
|
+
const breakpointHandler = getBreakpointHandler();
|
|
39
|
+
setMatchedBreakpoints((previousMatchedBreakpoints) => {
|
|
40
|
+
if (previousMatchedBreakpoints.length !== breakpointHandler.length || previousMatchedBreakpoints.some((breakpoint, idx) => breakpoint !== breakpointHandler[idx])) {
|
|
41
|
+
return [...breakpointHandler];
|
|
42
|
+
}
|
|
43
|
+
return previousMatchedBreakpoints;
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
window.addEventListener("resize", handleResize);
|
|
47
|
+
return () => {
|
|
48
|
+
window.removeEventListener("resize", handleResize);
|
|
49
|
+
};
|
|
50
|
+
}, [getBreakpointHandler]);
|
|
51
|
+
const isSSR = useIsSSR();
|
|
52
|
+
return isSSR ? [unsupportedMatchMediaBreakpoint] : matchedBreakpoints;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { BreakpointProvider, DefaultUnsupportedMatchMediaBreakpoint };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useIsomorphicLayoutEffect } from './chunk-3YM73BQP.js';
|
|
2
|
+
import { ThemeComputedStyle } from './chunk-JQBON2KA.js';
|
|
3
|
+
import { useInsertStyleElement } from './chunk-JBWKRDVA.js';
|
|
4
|
+
import { StyledSystemRootCssClass } from './chunk-ZQUJDDQL.js';
|
|
5
|
+
import { isNil } from './chunk-U5R6ZXH3.js';
|
|
6
|
+
import { useColorSchemeContext } from './chunk-V7X6ANEM.js';
|
|
7
|
+
import { useRef, useState } from 'react';
|
|
8
|
+
import { jsx } from 'react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
var BodyTokens = {
|
|
11
|
+
color: "--hop-neutral-text",
|
|
12
|
+
backgroundColor: "--hop-neutral-surface",
|
|
13
|
+
lineHeight: "--hop-body-md-line-height",
|
|
14
|
+
fontFamily: "--hop-body-md-font-family",
|
|
15
|
+
fontSize: "--hop-body-md-font-size"
|
|
16
|
+
};
|
|
17
|
+
function BodyStyleProvider() {
|
|
18
|
+
const ref = useRef(null);
|
|
19
|
+
const { colorScheme } = useColorSchemeContext();
|
|
20
|
+
const [cosmeticStyles, setCosmeticStyles] = useState(void 0);
|
|
21
|
+
useIsomorphicLayoutEffect(() => {
|
|
22
|
+
if (ref.current) {
|
|
23
|
+
const computedStyle = new ThemeComputedStyle(ref, `.${StyledSystemRootCssClass}`);
|
|
24
|
+
const color = computedStyle.getPropertyValue(BodyTokens.color);
|
|
25
|
+
const backgroundColor = computedStyle.getPropertyValue(BodyTokens.backgroundColor);
|
|
26
|
+
const fontFamily = computedStyle.getPropertyValue(BodyTokens.fontFamily);
|
|
27
|
+
const lineHeight = computedStyle.getPropertyValue(BodyTokens.lineHeight);
|
|
28
|
+
const fontSize = computedStyle.getPropertyValue(BodyTokens.fontSize);
|
|
29
|
+
setCosmeticStyles({ colorScheme, color, backgroundColor, lineHeight, fontFamily, fontSize });
|
|
30
|
+
}
|
|
31
|
+
}, [ref, colorScheme]);
|
|
32
|
+
useInsertStyleElement(
|
|
33
|
+
`hop-body-styles-${StyledSystemRootCssClass}`,
|
|
34
|
+
isNil(cosmeticStyles) ? "" : generateBodyCssContent(cosmeticStyles)
|
|
35
|
+
);
|
|
36
|
+
return /* @__PURE__ */ jsx("div", { ref });
|
|
37
|
+
}
|
|
38
|
+
function generateBodyCssContent({ color, backgroundColor, fontFamily, lineHeight, fontSize }) {
|
|
39
|
+
return `
|
|
40
|
+
body {
|
|
41
|
+
-webkit-font-smoothing: antialiased;
|
|
42
|
+
font-family: ${fontFamily}, Arial, sans-serif;
|
|
43
|
+
line-height: ${lineHeight};
|
|
44
|
+
font-size: ${fontSize};
|
|
45
|
+
color: ${color};
|
|
46
|
+
background-color: ${backgroundColor};
|
|
47
|
+
margin: 0;
|
|
48
|
+
padding: 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@media not (prefers-reduced-motion) {
|
|
52
|
+
body {
|
|
53
|
+
scroll-behavior: smooth;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { BodyStyleProvider };
|