@crfrsr/ui 1.0.0
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/dist/ThemeProvider.d.ts +22 -0
- package/dist/ThemeProvider.js +53 -0
- package/dist/components/Button.d.ts +14 -0
- package/dist/components/Button.js +12 -0
- package/dist/components/Combobox.d.ts +33 -0
- package/dist/components/Combobox.js +255 -0
- package/dist/components/Pill.d.ts +20 -0
- package/dist/components/Pill.js +19 -0
- package/dist/components/command.d.ts +74 -0
- package/dist/components/command.js +26 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +6 -0
- package/dist/components/popover.d.ts +7 -0
- package/dist/components/popover.js +10 -0
- package/dist/hooks/useIsMobile.d.ts +8 -0
- package/dist/hooks/useIsMobile.js +18 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/lib/cn.d.ts +7 -0
- package/dist/lib/cn.js +9 -0
- package/dist/styles/button.css +89 -0
- package/dist/styles/combobox.css +200 -0
- package/dist/styles/pill.css +44 -0
- package/dist/styles/reset.css +273 -0
- package/dist/styles/styles.css +14 -0
- package/dist/styles/tokens.css +100 -0
- package/dist/typography/Heading.d.ts +12 -0
- package/dist/typography/Heading.js +31 -0
- package/dist/typography/Text.d.ts +13 -0
- package/dist/typography/Text.js +21 -0
- package/dist/typography/index.d.ts +2 -0
- package/dist/typography/index.js +2 -0
- package/package.json +72 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
export interface HeadingProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
5
|
+
weight?: 'normal' | 'medium' | 'semibold' | 'bold';
|
|
6
|
+
color?: 'text' | 'textSecondary' | 'primary' | 'secondary';
|
|
7
|
+
align?: 'left' | 'center' | 'right';
|
|
8
|
+
lineHeight?: 'tight' | 'normal' | 'relaxed';
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function Heading({ children, level, weight, color, align, lineHeight, style, className, }: HeadingProps): React.JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTheme } from '../ThemeProvider';
|
|
3
|
+
const variantMap = {
|
|
4
|
+
1: '4xl',
|
|
5
|
+
2: '3xl',
|
|
6
|
+
3: '2xl',
|
|
7
|
+
4: 'xl',
|
|
8
|
+
5: 'lg',
|
|
9
|
+
6: 'base',
|
|
10
|
+
};
|
|
11
|
+
export function Heading({ children, level, weight, color, align, lineHeight, style, className, }) {
|
|
12
|
+
const { theme } = useTheme();
|
|
13
|
+
const variant = variantMap[level];
|
|
14
|
+
const Component = `h${level}`;
|
|
15
|
+
const headingStyle = {
|
|
16
|
+
// fontFamily is set globally, no need to set it here
|
|
17
|
+
// fontSize is set based on level (heading semantic sizing)
|
|
18
|
+
fontSize: theme.typography.fontSize[variant],
|
|
19
|
+
// Only set fontWeight if weight is explicitly provided
|
|
20
|
+
...(weight && { fontWeight: theme.typography.fontWeight[weight] }),
|
|
21
|
+
// Only set lineHeight if explicitly provided
|
|
22
|
+
...(lineHeight && { lineHeight: theme.typography.lineHeight[lineHeight] }),
|
|
23
|
+
// Only set color if explicitly provided (defaults to body text color)
|
|
24
|
+
...(color && { color: theme.colors[color] }),
|
|
25
|
+
// Only set textAlign if explicitly provided
|
|
26
|
+
...(align && { textAlign: align }),
|
|
27
|
+
margin: 0,
|
|
28
|
+
...style,
|
|
29
|
+
};
|
|
30
|
+
return (React.createElement(Component, { style: headingStyle, className: className }, children));
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
export interface TextProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
variant?: 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
|
|
5
|
+
weight?: 'normal' | 'medium' | 'semibold' | 'bold';
|
|
6
|
+
color?: 'text' | 'textSecondary' | 'textDisabled' | 'primary' | 'secondary' | 'success' | 'warning' | 'error' | 'info';
|
|
7
|
+
align?: 'left' | 'center' | 'right' | 'justify';
|
|
8
|
+
lineHeight?: 'tight' | 'normal' | 'relaxed';
|
|
9
|
+
as?: 'p' | 'span' | 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function Text({ children, variant, weight, color, align, lineHeight, as: Component, style, className, }: TextProps): React.JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTheme } from '../ThemeProvider';
|
|
3
|
+
export function Text({ children, variant, weight, color, align, lineHeight, as: Component = 'p', style, className, }) {
|
|
4
|
+
const { theme } = useTheme();
|
|
5
|
+
const textStyle = {
|
|
6
|
+
// fontFamily is set globally, no need to set it here
|
|
7
|
+
// Only set fontSize if variant is explicitly provided
|
|
8
|
+
...(variant && { fontSize: theme.typography.fontSize[variant] }),
|
|
9
|
+
// Only set fontWeight if weight is explicitly provided
|
|
10
|
+
...(weight && { fontWeight: theme.typography.fontWeight[weight] }),
|
|
11
|
+
// Only set lineHeight if explicitly provided
|
|
12
|
+
...(lineHeight && { lineHeight: theme.typography.lineHeight[lineHeight] }),
|
|
13
|
+
// Only set color if explicitly provided (defaults to body text color)
|
|
14
|
+
...(color && { color: theme.colors[color] }),
|
|
15
|
+
// Only set textAlign if explicitly provided
|
|
16
|
+
...(align && { textAlign: align }),
|
|
17
|
+
margin: 0,
|
|
18
|
+
...style,
|
|
19
|
+
};
|
|
20
|
+
return (React.createElement(Component, { style: textStyle, className: className }, children));
|
|
21
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crfrsr/ui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "crfrsr Design System components for React (web)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"design-system",
|
|
7
|
+
"react",
|
|
8
|
+
"components",
|
|
9
|
+
"typography",
|
|
10
|
+
"theme",
|
|
11
|
+
"dark-mode",
|
|
12
|
+
"crfrsr"
|
|
13
|
+
],
|
|
14
|
+
"author": "Cristian Fraser",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"homepage": "https://github.com/cristianfraser/crfrsr#readme",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/cristianfraser/crfrsr/issues"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/cristianfraser/crfrsr.git",
|
|
23
|
+
"directory": "packages/react"
|
|
24
|
+
},
|
|
25
|
+
"main": "dist/index.js",
|
|
26
|
+
"module": "dist/index.js",
|
|
27
|
+
"types": "dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./reset.css": "./dist/styles/reset.css",
|
|
34
|
+
"./tokens.css": "./dist/styles/tokens.css",
|
|
35
|
+
"./styles.css": "./dist/styles/styles.css",
|
|
36
|
+
"./package.json": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
"sideEffects": [
|
|
39
|
+
"**/*.css"
|
|
40
|
+
],
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
],
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc && node scripts/copy-styles.mjs",
|
|
48
|
+
"clean": "rm -rf dist",
|
|
49
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"react": ">=18.0.0",
|
|
53
|
+
"react-dom": ">=18.0.0"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@crfrsr/core": "^1.0.0",
|
|
57
|
+
"@radix-ui/react-popover": "^1.1.2",
|
|
58
|
+
"@tanstack/react-virtual": "^3.10.8",
|
|
59
|
+
"clsx": "^2.1.1",
|
|
60
|
+
"cmdk": "^1.0.0"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/react": "^18.2.43",
|
|
64
|
+
"@types/react-dom": "^18.2.17",
|
|
65
|
+
"react": "^18.2.0",
|
|
66
|
+
"react-dom": "^18.2.0",
|
|
67
|
+
"typescript": "^5.3.3"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public"
|
|
71
|
+
}
|
|
72
|
+
}
|