Skip to content

Commit 88b6aac

Browse files
committed
Update Scope.jsx
1 parent ebd4619 commit 88b6aac

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

scope/Scope.jsx

+23-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
// @ts-check
2+
13
// Scoped CSS component
24
// https://developer.mozilla.org/en-US/docs/Web/CSS/@scope
35
// Influenced by https://x.com/dburles/status/1848236095173226873
46

57
/**
6-
* @param {string} [href] - Optional URL for stylesheet
7-
* @param {string} [css] - Optional CSS string for scoped styles
8-
* @param {import('react').ReactNode} children - Child elements
9-
* @returns {JSX.Element} Scoped component
8+
* A component that provides CSS scoping functionality
9+
* @param {Object} props - The component props
10+
* @param {string} [props.href] - Optional URL to an external stylesheet
11+
* @param {string} [props.css] - Optional CSS string to scope
12+
* @param {React.ReactNode} [props.children] - Child elements to scope the styles to
13+
* @returns {JSX.Element} The scoped component
1014
*/
11-
const Scope = (href, css, children) => {
15+
const Scope = ({ href, css, children }) => {
1216
return (
1317
<ultra-scope>
1418
{href && <link rel="stylesheet" href={href} />}
@@ -25,3 +29,17 @@ const Scope = (href, css, children) => {
2529
</ultra-scope>
2630
);
2731
};
32+
33+
export default Scope;
34+
35+
/**
36+
* @param {string} a
37+
* @param {any} s
38+
*/
39+
const css = (a, s) => {
40+
const c = new String(a);
41+
// @ts-ignore html escaped string
42+
return (c.isEscaped = !0), (c.callbacks = s), c;
43+
};
44+
45+
export { css };

0 commit comments

Comments
 (0)