@times-design-system/theme-css 1.1.1-alpha.831
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/README.md +190 -0
- package/dist/index.js +8 -0
- package/dist/variables.css +6578 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# @times-design-system/theme-react
|
|
2
|
+
|
|
3
|
+
Times Design System theme tokens, React hooks, and CSS variables for building themed applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @times-design-system/theme-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### JavaScript/React Tokens & Hooks
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import { tokens, useTypographyToken } from '@times-design-system/theme-react';
|
|
17
|
+
|
|
18
|
+
// Use design tokens
|
|
19
|
+
console.log(tokens.Foundation.fontSize100); // "2.25rem"
|
|
20
|
+
console.log(tokens.semanticColor.text.primary); // "rgba(26, 26, 26, 1.00)"
|
|
21
|
+
|
|
22
|
+
// Use typography hook in React components
|
|
23
|
+
const MyComponent = () => {
|
|
24
|
+
const headingStyle = useTypographyToken('brand.heading.fluid.bold.large');
|
|
25
|
+
return <h1 style={headingStyle}>Heading</h1>;
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### CSS Custom Properties
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<!-- Link the CSS variables -->
|
|
33
|
+
<link
|
|
34
|
+
rel="stylesheet"
|
|
35
|
+
href="node_modules/@times-design-system/theme-react/variables.css"
|
|
36
|
+
/>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```css
|
|
40
|
+
/* Use CSS variables in your stylesheets */
|
|
41
|
+
:root {
|
|
42
|
+
--tds-font-size100: 2.25rem;
|
|
43
|
+
--tds-font-size050: 1.25rem;
|
|
44
|
+
--tds-spacing-050: 0.5rem;
|
|
45
|
+
/* 2,748+ design tokens as CSS variables */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
h1 {
|
|
49
|
+
font-size: var(--tds-font-size100);
|
|
50
|
+
margin: var(--tds-spacing-050);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Import only specific modules
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
// Tokens only
|
|
58
|
+
import { tokens } from '@times-design-system/theme-react/tokens';
|
|
59
|
+
|
|
60
|
+
// Hooks only
|
|
61
|
+
import { useTypographyToken } from '@times-design-system/theme-react/hooks';
|
|
62
|
+
|
|
63
|
+
// CSS only (already in package.json exports)
|
|
64
|
+
import '@times-design-system/theme-react/variables.css';
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Available Exports
|
|
68
|
+
|
|
69
|
+
### JavaScript Modules
|
|
70
|
+
|
|
71
|
+
- **tokens** - Complete design token object with all Foundation, Palette, and Semantic tokens
|
|
72
|
+
- **useTypographyToken** - React hook for applying typography styles to elements
|
|
73
|
+
|
|
74
|
+
### CSS
|
|
75
|
+
|
|
76
|
+
- **variables.css** - 2,748+ CSS custom properties (--tds-\*) covering:
|
|
77
|
+
- Font sizes: --tds-font-size0025 through --tds-font-size190
|
|
78
|
+
- Spacing: --tds-spacing-\* (fluid and static variants)
|
|
79
|
+
- Shadows: --tds-elevation-\*
|
|
80
|
+
- Colors: --tds-brand-_, --tds-semantic-_, etc.
|
|
81
|
+
|
|
82
|
+
## Package Contents
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
dist/
|
|
86
|
+
├── index.js/cjs # Main export (tokens + hooks)
|
|
87
|
+
├── tokens.js/cjs # Design tokens only
|
|
88
|
+
├── hooks.js/cjs # React hooks only
|
|
89
|
+
└── variables.css # CSS custom properties
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Token Structure
|
|
93
|
+
|
|
94
|
+
#### Foundation Tokens
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
tokens.Foundation.fontSize010; // "0.75rem"
|
|
98
|
+
tokens.Foundation.fontSize100; // "2.25rem"
|
|
99
|
+
tokens.Foundation.spacing050; // "0.5rem"
|
|
100
|
+
tokens.Foundation.spacing100; // "1rem"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Palette Tokens (Pre-resolved Colors)
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
tokens.brand.primary; // Color ramp with 19 steps (100-1000)
|
|
107
|
+
tokens.channels.comment; // Channel-specific colors
|
|
108
|
+
tokens.dataVisualisation.data01; // Data visualization colors
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Semantic Tokens
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
tokens.semanticColor.surface.default; // "rgba(255, 255, 255, 1.00)"
|
|
115
|
+
tokens.semanticColor.text.primary; // "rgba(26, 26, 26, 1.00)"
|
|
116
|
+
tokens.semanticColor.interactive.primary; // Brand color for interactive elements
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## React Hook Usage
|
|
120
|
+
|
|
121
|
+
### useTypographyToken(tokenPath)
|
|
122
|
+
|
|
123
|
+
Returns style object ready for use in React:
|
|
124
|
+
|
|
125
|
+
```javascript
|
|
126
|
+
const { useTypographyToken } from '@times-design-system/theme-react/hooks';
|
|
127
|
+
|
|
128
|
+
export const Article = ({ title }) => {
|
|
129
|
+
// Get typography style for display heading
|
|
130
|
+
const headingStyle = useTypographyToken('brand.heading.fluid.bold.large');
|
|
131
|
+
|
|
132
|
+
// Get typography style for body text
|
|
133
|
+
const bodyStyle = useTypographyToken('utility.body.static.regular.medium');
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<>
|
|
137
|
+
<h1 style={headingStyle}>{title}</h1>
|
|
138
|
+
<p style={bodyStyle}>Article content...</p>
|
|
139
|
+
</>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Returns object:
|
|
145
|
+
|
|
146
|
+
```javascript
|
|
147
|
+
{
|
|
148
|
+
fontFamily: 'Times Modern, serif',
|
|
149
|
+
fontSize: '2.25rem',
|
|
150
|
+
fontWeight: 700,
|
|
151
|
+
lineHeight: 1.2,
|
|
152
|
+
letterSpacing: '-0.02em'
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Browser Support
|
|
157
|
+
|
|
158
|
+
All CSS custom properties (--tds-\*) are supported in modern browsers (Chrome, Firefox, Safari, Edge).
|
|
159
|
+
|
|
160
|
+
For older browsers, use the JavaScript tokens with fallback values:
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
const fontSize = tokens.Foundation.fontSize100 || '2.25rem';
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Building
|
|
167
|
+
|
|
168
|
+
To rebuild the package after modifying tokens:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
npm run build
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
This will:
|
|
175
|
+
|
|
176
|
+
1. Clean the `dist/` directory
|
|
177
|
+
2. Build ESM and CJS JavaScript modules
|
|
178
|
+
3. Copy CSS variables to dist/
|
|
179
|
+
|
|
180
|
+
## Publishing
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
npm publish
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The package is configured with public access and will publish to the public npm registry.
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
ISC
|