@times-design-system/components-wordpress 1.9.0 → 1.10.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/blocks/ad-container/style.css +1 -30
- package/dist/blocks/ad-container/style.scss +70 -0
- package/dist/blocks/button/block.json +67 -1
- package/dist/blocks/button/init.js +45 -0
- package/dist/blocks/button/render.php +2 -0
- package/dist/blocks/button/style.css +1 -203
- package/dist/blocks/button/style.scss +204 -0
- package/dist/blocks/chip/ONCLICK_USAGE.md +263 -0
- package/dist/blocks/chip/block.json +22 -3
- package/dist/blocks/chip/init.js +60 -0
- package/dist/blocks/chip/render.php +7 -2
- package/dist/blocks/chip/style.css +1 -108
- package/dist/blocks/chip/style.scss +213 -0
- package/dist/blocks/dialog-box/style.css +1 -23
- package/dist/blocks/dialog-box/style.scss +113 -0
- package/dist/blocks/divider/style.css +1 -37
- package/dist/blocks/divider/style.scss +40 -0
- package/dist/blocks/icon/block.json +10 -1
- package/dist/blocks/icon/style.css +1 -23
- package/dist/blocks/icon/style.scss +10 -0
- package/dist/blocks/icon-button/block.json +41 -0
- package/dist/blocks/icon-button/init.js +56 -0
- package/dist/blocks/icon-button/render.php +5 -0
- package/dist/blocks/icon-button/style.css +1 -66
- package/dist/blocks/icon-button/style.scss +189 -0
- package/dist/blocks/input/style.css +1 -67
- package/dist/blocks/input/style.scss +72 -0
- package/dist/blocks/input-helper-message/style.css +1 -23
- package/dist/blocks/input-helper-message/style.scss +45 -0
- package/dist/blocks/link/block.json +86 -3
- package/dist/blocks/link/init.js +54 -0
- package/dist/blocks/link/render.php +22 -12
- package/dist/blocks/link/style.css +1 -221
- package/dist/blocks/link/style.scss +163 -0
- package/dist/blocks/tab/style.css +1 -152
- package/dist/blocks/tab/style.scss +159 -0
- package/dist/blocks/tab-group/style.css +1 -23
- package/dist/blocks/tab-group/style.scss +32 -0
- package/dist/blocks/{flag → tag}/block.json +46 -14
- package/dist/blocks/{flag → tag}/edit.js +9 -20
- package/dist/blocks/{flag → tag}/index.js +2 -2
- package/dist/blocks/{flag → tag}/render.php +24 -19
- package/dist/blocks/tag/save.js +23 -0
- package/dist/blocks/{chip → tag}/style-editor.css +2 -2
- package/dist/blocks/tag/style.css +1 -0
- package/dist/blocks/tag/style.scss +115 -0
- package/dist/blocks/text/style.css +1 -7
- package/dist/blocks/text/style.scss +11 -0
- package/dist/blocks/toast/style.css +1 -68
- package/dist/blocks/toast/style.scss +67 -0
- package/dist/blocks/utils/render-icon.php +72 -5
- package/dist/icon-data.json +1 -1
- package/dist/index.cjs +391 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +391 -54
- package/dist/index.js.map +1 -1
- package/dist/plugin.php +42 -0
- package/dist/utils/render-icon.php +11 -2
- package/package.json +6 -4
- package/plugin.php +42 -0
- package/dist/blocks/flag/save.js +0 -25
- package/dist/blocks/flag/style-editor.css +0 -5
- package/dist/blocks/flag/style.css +0 -72
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# Chip Block onClick Attribute Usage Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Chip block now supports an `onClick` attribute that allows you to:
|
|
6
|
+
|
|
7
|
+
1. **Toggle visual state** - The chip automatically toggles between `tds-chip--toggle-on` and `tds-chip--toggle-off` CSS classes when clicked
|
|
8
|
+
2. **Execute custom JavaScript** - Call any JavaScript function in your global scope when the chip is clicked
|
|
9
|
+
|
|
10
|
+
## How It Works
|
|
11
|
+
|
|
12
|
+
### Visual Toggle
|
|
13
|
+
|
|
14
|
+
When a user clicks the chip, the CSS classes are automatically toggled:
|
|
15
|
+
|
|
16
|
+
- **Initial state**: `tds-chip--toggle-off`
|
|
17
|
+
- **After click**: `tds-chip--toggle-on`
|
|
18
|
+
- **After second click**: `tds-chip--toggle-off`
|
|
19
|
+
|
|
20
|
+
This happens without any custom code - it's handled by the `init.js` click handler.
|
|
21
|
+
|
|
22
|
+
### Custom onClick Handler
|
|
23
|
+
|
|
24
|
+
You can pass the name of a JavaScript function to be called when the chip is clicked:
|
|
25
|
+
|
|
26
|
+
```php
|
|
27
|
+
// In your WordPress template or block configuration
|
|
28
|
+
$attributes = [
|
|
29
|
+
'content' => 'Filter: Technology',
|
|
30
|
+
'onClick' => 'handleFilterClick', // Function name to call
|
|
31
|
+
'intent' => 'primary',
|
|
32
|
+
'size' => 'small'
|
|
33
|
+
];
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage Examples
|
|
37
|
+
|
|
38
|
+
### Example 1: Simple Filter Chip
|
|
39
|
+
|
|
40
|
+
**Template/Block Code:**
|
|
41
|
+
|
|
42
|
+
```php
|
|
43
|
+
<?php
|
|
44
|
+
echo do_blocks( '<!-- wp:tds/chip {"content":"Technology","intent":"primary","size":"small","onClick":"handleFilterClick"} /-->' );
|
|
45
|
+
?>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**JavaScript (in your theme or plugin):**
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
// Define globally accessible function
|
|
52
|
+
window.handleFilterClick = function (event) {
|
|
53
|
+
// event = click event
|
|
54
|
+
// this = chip element (button.tds-chip)
|
|
55
|
+
|
|
56
|
+
const chipElement = this;
|
|
57
|
+
const label = chipElement.querySelector('.tds-chip__label').textContent;
|
|
58
|
+
const isActive = chipElement.classList.contains('tds-chip--toggle-on');
|
|
59
|
+
|
|
60
|
+
console.log(`Filter "${label}" toggled to: ${isActive ? 'on' : 'off'}`);
|
|
61
|
+
|
|
62
|
+
// Example: Send state to server
|
|
63
|
+
fetch('/api/filter-update', {
|
|
64
|
+
method: 'POST',
|
|
65
|
+
headers: { 'Content-Type': 'application/json' },
|
|
66
|
+
body: JSON.stringify({
|
|
67
|
+
filter: label,
|
|
68
|
+
active: isActive
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Example 2: Multiple Chips with Shared Handler
|
|
75
|
+
|
|
76
|
+
**Template/Block Code:**
|
|
77
|
+
|
|
78
|
+
```php
|
|
79
|
+
<?php
|
|
80
|
+
$filters = ['Technology', 'Science', 'Business'];
|
|
81
|
+
foreach ($filters as $filter) {
|
|
82
|
+
echo do_blocks(
|
|
83
|
+
'<!-- wp:tds/chip {"content":"' . $filter . '","onClick":"toggleFilter"} /-->'
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
?>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**JavaScript:**
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
window.toggleFilter = function (event) {
|
|
93
|
+
const chipElement = this;
|
|
94
|
+
const filterName = chipElement.querySelector('.tds-chip__label').textContent;
|
|
95
|
+
const isActive = chipElement.classList.contains('tds-chip--toggle-on');
|
|
96
|
+
|
|
97
|
+
// Add/remove filter from active list
|
|
98
|
+
if (isActive) {
|
|
99
|
+
addFilter(filterName);
|
|
100
|
+
} else {
|
|
101
|
+
removeFilter(filterName);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
function addFilter(name) {
|
|
106
|
+
console.log('Adding filter:', name);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function removeFilter(name) {
|
|
110
|
+
console.log('Removing filter:', name);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Example 3: Analytics Tracking
|
|
115
|
+
|
|
116
|
+
**Template/Block Code:**
|
|
117
|
+
|
|
118
|
+
```php
|
|
119
|
+
<?php
|
|
120
|
+
echo do_blocks( '<!-- wp:tds/chip {"content":"Save This","onClick":"trackChipClick"} /-->' );
|
|
121
|
+
?>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**JavaScript:**
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
window.trackChipClick = function (event) {
|
|
128
|
+
// Track in your analytics system
|
|
129
|
+
if (typeof gtag !== 'undefined') {
|
|
130
|
+
gtag('event', 'chip_click', {
|
|
131
|
+
chip_label: this.querySelector('.tds-chip__label').textContent,
|
|
132
|
+
toggle_state: this.classList.contains('tds-chip--toggle-on')
|
|
133
|
+
? 'on'
|
|
134
|
+
: 'off'
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## CSS Classes for Styling
|
|
141
|
+
|
|
142
|
+
The chip automatically applies these classes based on toggle state:
|
|
143
|
+
|
|
144
|
+
```scss
|
|
145
|
+
// Initial (not toggled)
|
|
146
|
+
.tds-chip--toggle-off {
|
|
147
|
+
// Default styles
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// After click (toggled)
|
|
151
|
+
.tds-chip--toggle-on {
|
|
152
|
+
// You can add activation styling in your SCSS
|
|
153
|
+
background-color: darken($interactive-primary-fill-default, 10%);
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Add styling to your block's SCSS:**
|
|
158
|
+
|
|
159
|
+
```scss
|
|
160
|
+
// packages/components-wordpress/src/blocks/chip/style.scss
|
|
161
|
+
|
|
162
|
+
.tds-chip--toggle-on {
|
|
163
|
+
--tds-chip-bg: #{darken($interactive-primary-fill-default, 10%)};
|
|
164
|
+
// Add any other active state styling
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Implementation Details
|
|
169
|
+
|
|
170
|
+
### Files Modified
|
|
171
|
+
|
|
172
|
+
1. **render.php**
|
|
173
|
+
- Extracts `onClick` attribute from block attributes
|
|
174
|
+
- Adds `data-onclick` attribute to button element if onClick is provided
|
|
175
|
+
|
|
176
|
+
2. **block.json**
|
|
177
|
+
- Defines `onClick` attribute as a string type
|
|
178
|
+
- Stores function name to be called
|
|
179
|
+
|
|
180
|
+
3. **init.js** (NEW)
|
|
181
|
+
- Queries all chips with `data-onclick` attribute
|
|
182
|
+
- Sets up click event listeners
|
|
183
|
+
- Handles toggle state UI
|
|
184
|
+
- Calls custom onClick function from global scope
|
|
185
|
+
|
|
186
|
+
### Execution Flow
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
User clicks chip
|
|
190
|
+
↓
|
|
191
|
+
init.js click handler fires
|
|
192
|
+
↓
|
|
193
|
+
1. Toggle CSS classes (toggle-on ↔ toggle-off)
|
|
194
|
+
↓
|
|
195
|
+
2. Call window[functionName] if it exists
|
|
196
|
+
↓
|
|
197
|
+
Your custom function executes with:
|
|
198
|
+
- this = chip element
|
|
199
|
+
- event = click event
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Important Notes
|
|
203
|
+
|
|
204
|
+
1. **Function Name Only**: Pass the function name as a string, not the function itself
|
|
205
|
+
- ✅ Correct: `"onClick": "handleFilterClick"`
|
|
206
|
+
- ❌ Wrong: `"onClick": "handleFilterClick()"`
|
|
207
|
+
|
|
208
|
+
2. **Global Scope**: Functions must be defined in `window` scope
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
// ✅ Correct - globally accessible
|
|
212
|
+
window.handleFilterClick = function(event) { ... };
|
|
213
|
+
|
|
214
|
+
// ❌ Wrong - not accessible
|
|
215
|
+
const handleFilterClick = function(event) { ... };
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
3. **Function Context**: Your function is called with the chip button as `this`
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
window.handleFilterClick = function (event) {
|
|
222
|
+
// this = button.tds-chip element
|
|
223
|
+
// event = click event
|
|
224
|
+
this.classList.contains('tds-chip--toggle-on'); // Check current state
|
|
225
|
+
};
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
4. **Toggle Always Happens**: The toggle state change happens automatically before your function is called. You don't need to manage it manually.
|
|
229
|
+
|
|
230
|
+
5. **Timing**: Functions must be defined BEFORE the page is fully loaded for chips to work. Either:
|
|
231
|
+
- Use `<script>` tags in your theme's `functions.php`
|
|
232
|
+
- Add to `wp_footer` hook
|
|
233
|
+
- Load in a theme JS file
|
|
234
|
+
|
|
235
|
+
## Testing in Preview
|
|
236
|
+
|
|
237
|
+
The preview HTML includes the init.js handler, but to test with your onClick function:
|
|
238
|
+
|
|
239
|
+
1. Open `preview/index.html` in a browser
|
|
240
|
+
2. Open Developer Tools Console
|
|
241
|
+
3. Define your function:
|
|
242
|
+
```javascript
|
|
243
|
+
window.handleFilterClick = function (event) {
|
|
244
|
+
console.log('Chip clicked!');
|
|
245
|
+
};
|
|
246
|
+
```
|
|
247
|
+
4. Click a chip with `data-onclick="handleFilterClick"`
|
|
248
|
+
|
|
249
|
+
## Security Considerations
|
|
250
|
+
|
|
251
|
+
⚠️ **Important**: The onClick attribute stores a function name as a string. Only execute functions you control:
|
|
252
|
+
|
|
253
|
+
```php
|
|
254
|
+
// ✅ Safe - control which functions can be called
|
|
255
|
+
$allowed_functions = ['toggleFilter', 'trackChipClick', 'handleFilterClick'];
|
|
256
|
+
$onclick = isset($attributes['onClick']) ? $attributes['onClick'] : '';
|
|
257
|
+
|
|
258
|
+
if (!in_array($onclick, $allowed_functions)) {
|
|
259
|
+
$onclick = ''; // Ignore untrusted function names
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
The current implementation sanitizes the function name with `sanitize_text_field()` which removes dangerous characters, but consider adding a whitelist in your WordPress theme or plugin.
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
},
|
|
21
21
|
"intent": {
|
|
22
22
|
"type": "string",
|
|
23
|
-
"default": "
|
|
23
|
+
"default": "primary",
|
|
24
24
|
"enum": ["primary", "secondary"]
|
|
25
25
|
},
|
|
26
26
|
"size": {
|
|
27
27
|
"type": "string",
|
|
28
|
-
"default": "
|
|
28
|
+
"default": "small",
|
|
29
29
|
"enum": ["small", "large"]
|
|
30
30
|
},
|
|
31
31
|
"channel": {
|
|
@@ -50,6 +50,11 @@
|
|
|
50
50
|
"type": "string",
|
|
51
51
|
"default": ""
|
|
52
52
|
},
|
|
53
|
+
"onClick": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"default": "",
|
|
56
|
+
"description": "Name of JavaScript function to call on click (e.g., 'myFunction'). Function receives click event and chip element context."
|
|
57
|
+
},
|
|
53
58
|
"classes": {
|
|
54
59
|
"type": "string",
|
|
55
60
|
"default": "",
|
|
@@ -63,5 +68,19 @@
|
|
|
63
68
|
},
|
|
64
69
|
"example": {},
|
|
65
70
|
"script": "times-design-system",
|
|
66
|
-
"editorScript": "times-design-system"
|
|
71
|
+
"editorScript": "times-design-system",
|
|
72
|
+
"preview": {
|
|
73
|
+
"combinations": [
|
|
74
|
+
{ "content": "Primary Small", "intent": "primary", "size": "small" },
|
|
75
|
+
{ "content": "Primary Large", "intent": "primary", "size": "large" },
|
|
76
|
+
{ "content": "Secondary", "intent": "secondary", "size": "small" },
|
|
77
|
+
{ "content": "Channel", "channel": true, "size": "small" },
|
|
78
|
+
{
|
|
79
|
+
"content": "Toggle",
|
|
80
|
+
"intent": "primary",
|
|
81
|
+
"toggle": true,
|
|
82
|
+
"size": "small"
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
67
86
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chip Block Click Handler
|
|
3
|
+
*
|
|
4
|
+
* Initializes click handlers for chip blocks with onClick attribute.
|
|
5
|
+
* Handles:
|
|
6
|
+
* - Toggle state visual feedback (tds-chip--toggle-on/off classes)
|
|
7
|
+
* - Custom onClick callback execution
|
|
8
|
+
*
|
|
9
|
+
* @package TimesDesignSystem\ComponentsWordPress
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
(function initChipClickHandlers() {
|
|
13
|
+
/**
|
|
14
|
+
* Initialize click handlers for all chip blocks
|
|
15
|
+
*/
|
|
16
|
+
function setupChipHandlers() {
|
|
17
|
+
const chips = document.querySelectorAll('.tds-chip');
|
|
18
|
+
|
|
19
|
+
if (chips.length === 0) {
|
|
20
|
+
console.warn('[TDS Chip] No chips found on page');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
chips.forEach((chip) => {
|
|
25
|
+
chip.addEventListener('click', function handleChipClick(e) {
|
|
26
|
+
// Get the onClick function name from data attribute
|
|
27
|
+
const functionName = this.getAttribute('data-onclick');
|
|
28
|
+
|
|
29
|
+
// Toggle visual state between on/off
|
|
30
|
+
const isCurrentlyOn = this.classList.contains('tds-chip--toggle-on');
|
|
31
|
+
|
|
32
|
+
if (isCurrentlyOn) {
|
|
33
|
+
this.classList.remove('tds-chip--toggle-on');
|
|
34
|
+
this.classList.add('tds-chip--toggle-off');
|
|
35
|
+
} else {
|
|
36
|
+
this.classList.remove('tds-chip--toggle-off');
|
|
37
|
+
this.classList.add('tds-chip--toggle-on');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Call custom onClick function if it exists in global scope
|
|
41
|
+
if (
|
|
42
|
+
functionName &&
|
|
43
|
+
window[functionName] &&
|
|
44
|
+
typeof window[functionName] === 'function'
|
|
45
|
+
) {
|
|
46
|
+
window[functionName].call(this, e);
|
|
47
|
+
} else if (functionName) {
|
|
48
|
+
console.warn(`[TDS Chip] Function not found: ${functionName}`);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Initialize on DOM ready
|
|
55
|
+
if (document.readyState === 'loading') {
|
|
56
|
+
document.addEventListener('DOMContentLoaded', setupChipHandlers);
|
|
57
|
+
} else {
|
|
58
|
+
setupChipHandlers();
|
|
59
|
+
}
|
|
60
|
+
})();
|
|
@@ -20,6 +20,7 @@ $channel = isset($attributes['channel']) ? (bool) $attributes['channel'] : false
|
|
|
20
20
|
$toggle = isset($attributes['toggle']) ? (bool) $attributes['toggle'] : false;
|
|
21
21
|
$icon_left = isset($attributes['iconLeft']) ? sanitize_text_field($attributes['iconLeft']) : '';
|
|
22
22
|
$icon_right = isset($attributes['iconRight']) ? sanitize_text_field($attributes['iconRight']) : '';
|
|
23
|
+
$on_click = isset($attributes['onClick']) ? sanitize_text_field($attributes['onClick']) : '';
|
|
23
24
|
|
|
24
25
|
// Derive icon size from chip size
|
|
25
26
|
$icon_size_map = [
|
|
@@ -44,8 +45,11 @@ if ($channel) {
|
|
|
44
45
|
$classes[] = 'tds-chip--channel';
|
|
45
46
|
}
|
|
46
47
|
if ($toggle) {
|
|
47
|
-
$
|
|
48
|
+
$toggleStatus = 'on';
|
|
49
|
+
} else {
|
|
50
|
+
$toggleStatus = 'off';
|
|
48
51
|
}
|
|
52
|
+
$classes[] = 'tds-chip--toggle-' . $toggleStatus;
|
|
49
53
|
if ($element_class_name) {
|
|
50
54
|
$classes[] = $element_class_name;
|
|
51
55
|
}
|
|
@@ -56,13 +60,14 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)
|
|
|
56
60
|
<button
|
|
57
61
|
<?php echo wp_kses_post($wrapper_attrs); ?>
|
|
58
62
|
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
63
|
+
<?php echo $on_click ? 'data-onclick="' . esc_attr($on_click) . '"' : ''; ?>
|
|
59
64
|
<?php echo wp_kses_post($data_attrs_html); ?>
|
|
60
65
|
>
|
|
61
66
|
<span class="tds-chip__content">
|
|
62
67
|
<?php if ($icon_left) : ?>
|
|
63
68
|
<span class="tds-chip__icon tds-chip__icon--left"><?php echo wp_kses_post(tds_render_icon($icon_left, $icon_size)); ?></span>
|
|
64
69
|
<?php endif; ?>
|
|
65
|
-
|
|
70
|
+
<span class="tds-chip__label"><?php echo wp_kses_post($content_text); ?></span>
|
|
66
71
|
<?php if ($icon_right) : ?>
|
|
67
72
|
<span class="tds-chip__icon tds-chip__icon--right"><?php echo wp_kses_post(tds_render_icon($icon_right, $icon_size)); ?></span>
|
|
68
73
|
<?php endif; ?>
|
|
@@ -1,108 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/* Using resolved design token values for self-contained styling */
|
|
3
|
-
|
|
4
|
-
.tds-chip {
|
|
5
|
-
--tds-chip-bg: #005c8a;
|
|
6
|
-
--tds-chip-bg-hover: #004e75;
|
|
7
|
-
--tds-chip-bg-pressed: #00496e;
|
|
8
|
-
--tds-chip-fg: #ffffff;
|
|
9
|
-
--tds-chip-fg-hover: #d9d9d9;
|
|
10
|
-
--tds-chip-fg-pressed: #cccccc;
|
|
11
|
-
--tds-chip-icon: #ffffff;
|
|
12
|
-
--tds-chip-icon-hover: #d9d9d9;
|
|
13
|
-
--tds-chip-icon-pressed: #cccccc;
|
|
14
|
-
--tds-chip-border: transparent;
|
|
15
|
-
--tds-chip-border-hover: transparent;
|
|
16
|
-
--tds-chip-border-pressed: transparent;
|
|
17
|
-
--tds-chip-focus-ring: #737373;
|
|
18
|
-
|
|
19
|
-
position: relative;
|
|
20
|
-
display: inline-flex;
|
|
21
|
-
align-items: center;
|
|
22
|
-
justify-content: center;
|
|
23
|
-
gap: 4px;
|
|
24
|
-
border: 1px solid var(--tds-chip-border);
|
|
25
|
-
border-radius: 9999px;
|
|
26
|
-
background-color: var(--tds-chip-bg);
|
|
27
|
-
color: var(--tds-chip-fg);
|
|
28
|
-
font-family: Roboto;
|
|
29
|
-
font-weight: 500;
|
|
30
|
-
line-height: 1;
|
|
31
|
-
white-space: nowrap;
|
|
32
|
-
cursor: pointer;
|
|
33
|
-
transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.tds-chip:hover:not(:disabled) {
|
|
37
|
-
background-color: var(--tds-chip-bg-hover);
|
|
38
|
-
border-color: var(--tds-chip-border-hover);
|
|
39
|
-
color: var(--tds-chip-fg-hover);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.tds-chip:active:not(:disabled) {
|
|
43
|
-
background-color: var(--tds-chip-bg-pressed);
|
|
44
|
-
border-color: var(--tds-chip-border-pressed);
|
|
45
|
-
color: var(--tds-chip-fg-pressed);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.tds-chip:focus-visible {
|
|
49
|
-
outline: none;
|
|
50
|
-
background-color: var(--tds-chip-bg-hover);
|
|
51
|
-
border-color: var(--tds-chip-border-hover);
|
|
52
|
-
color: var(--tds-chip-fg-hover);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.tds-chip:focus-visible::after {
|
|
56
|
-
content: '';
|
|
57
|
-
position: absolute;
|
|
58
|
-
inset: -4px;
|
|
59
|
-
border: 2px solid #737373;
|
|
60
|
-
border-radius: inherit;
|
|
61
|
-
pointer-events: none;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.tds-chip:disabled {
|
|
65
|
-
background-color: #bfbfbf;
|
|
66
|
-
border-color: transparent;
|
|
67
|
-
color: #d9d9d9;
|
|
68
|
-
cursor: not-allowed;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.tds-chip--size-small {
|
|
72
|
-
min-height: 36px;
|
|
73
|
-
padding: 0 12px;
|
|
74
|
-
font-size: 0.875rem; /* utility.button.small */
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.tds-chip--size-large {
|
|
78
|
-
min-height: 48px;
|
|
79
|
-
padding: 0 16px;
|
|
80
|
-
font-size: 1.125rem; /* utility.button.large */
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.tds-chip__content {
|
|
84
|
-
display: inline-flex;
|
|
85
|
-
align-items: center;
|
|
86
|
-
justify-content: center;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.tds-chip__icon {
|
|
90
|
-
display: inline-flex;
|
|
91
|
-
align-items: center;
|
|
92
|
-
justify-content: center;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.tds-chip--size-small .tds-chip__icon {
|
|
96
|
-
width: 16px;
|
|
97
|
-
height: 16px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.tds-chip--size-large .tds-chip__icon {
|
|
101
|
-
width: 20px;
|
|
102
|
-
height: 20px;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.tds-chip__icon svg {
|
|
106
|
-
width: 100%;
|
|
107
|
-
height: 100%;
|
|
108
|
-
}
|
|
1
|
+
.tds-grid{display:grid;grid-template-columns:repeat(4, 1fr);grid-gap:24px;margin-inline:20px;max-width:100%}@media(min-width: 720px){.tds-grid{grid-template-columns:repeat(12, 1fr);grid-gap:32px;margin-inline:24px;max-width:720px}}@media(min-width: 976px){.tds-grid{max-width:976px}}@media(min-width: 1096px){.tds-grid{max-width:1096px}}.tds-grid.tds-grid--full-width{max-width:100%}:root{--font-size0025: 0.5rem;--font-size005: 0.625rem;--font-size010: 0.75rem;--font-size020: 0.875rem;--font-size025: 0.9375rem;--font-size030: 1rem;--font-size035: 1.0625rem;--font-size040: 1.125rem;--font-size045: 1.1875rem;--font-size050: 1.25rem;--font-size060: 1.375rem;--font-size070: 1.5rem;--font-size080: 1.75rem;--font-size090: 2rem;--font-size095: 2.125rem;--font-size100: 2.25rem;--font-size105: 2.875rem;--font-size110: 2rem;--font-size120: 2.75rem;--font-size125: 2.8125rem;--font-size130: 3rem;--font-size140: 2.5rem;--font-size150: 4rem;--font-size155: 4.375rem;--font-size160: 5rem}@media(min-width: 440px){:root{--font-size090: 3rem;--font-size100: 2.5rem}}@media(min-width: 1024px){:root{--font-size100: 2.875rem}}@media(min-width: 1440px){:root{--font-size090: 3.25rem;--font-size100: 3.5rem;--font-size110: 2.5rem;--font-size140: 3.5rem}}.tds-chip{--tds-chip-bg: #005c8a;--tds-chip-bg-hover: #004e75;--tds-chip-bg-pressed: #00496e;--tds-chip-fg: #ffffff;--tds-chip-fg-hover: #d9d9d9;--tds-chip-fg-pressed: #cccccc;--tds-chip-icon: #ffffff;--tds-chip-icon-hover: #d9d9d9;--tds-chip-icon-pressed: #cccccc;--tds-chip-border: transparent;--tds-chip-border-hover: transparent;--tds-chip-border-pressed: transparent;--tds-chip-focus-ring: #737373;position:relative;display:inline-flex;align-items:center;justify-content:center;gap:4px;border:1px solid var(--tds-chip-border);border-radius:9999px;background-color:var(--tds-chip-bg);color:var(--tds-chip-fg);white-space:nowrap;cursor:pointer;transition:background-color .15s ease,border-color .15s ease,color .15s ease,box-shadow .15s ease}.tds-chip:hover:not(:disabled){background-color:var(--tds-chip-bg-hover);border-color:var(--tds-chip-border-hover);color:var(--tds-chip-fg-hover)}.tds-chip:active:not(:disabled){background-color:var(--tds-chip-bg-pressed);border-color:var(--tds-chip-border-pressed);color:var(--tds-chip-fg-pressed)}.tds-chip:focus-visible{outline:none;background-color:var(--tds-chip-bg-hover);border-color:var(--tds-chip-border-hover);color:var(--tds-chip-fg-hover)}.tds-chip:focus-visible::after{content:"";position:absolute;inset:calc(4px*-1);border:2px solid var(--tds-chip-focus-ring);border-radius:inherit;pointer-events:none}.tds-chip:disabled{background-color:#bfbfbf;border-color:rgba(0,0,0,0);color:#d9d9d9;cursor:not-allowed}.tds-chip--size-small{min-height:36px;padding:0 12px}.tds-chip--size-small .tds-chip__label{font:500 var(--font-size020)/1 Times Roboto}.tds-chip--size-small .tds-chip__icon{width:16px;height:16px}.tds-chip--size-large{min-height:48px;padding:0 16px}.tds-chip--size-large .tds-chip__label{font:500 var(--font-size090)/1 Times Roboto}.tds-chip--size-large .tds-chip__icon{width:20px;height:20px}.tds-chip__label{display:inline-flex;align-items:center;justify-content:center}.tds-chip__icon{display:inline-flex;align-items:center;justify-content:center;color:var(--tds-chip-icon)}.tds-chip:hover:not(:disabled) .tds-chip__icon,.tds-chip:focus-visible .tds-chip__icon{color:var(--tds-chip-icon-hover)}.tds-chip:active:not(:disabled) .tds-chip__icon{color:var(--tds-chip-icon-pressed)}.tds-chip:disabled .tds-chip__icon{color:#d9d9d9}.tds-chip--intent-primary.tds-chip--toggle-on{--tds-chip-bg: #005c8a;--tds-chip-bg-hover: #004e75;--tds-chip-bg-pressed: #00496e;--tds-chip-fg: #ffffff;--tds-chip-fg-hover: #d9d9d9;--tds-chip-fg-pressed: #cccccc;--tds-chip-icon: #ffffff;--tds-chip-icon-hover: #d9d9d9;--tds-chip-icon-pressed: #cccccc}.tds-chip--intent-primary.tds-chip--toggle-off{--tds-chip-bg: #f2f2f2;--tds-chip-bg-hover: #cecece;--tds-chip-bg-pressed: #c2c2c2;--tds-chip-fg: #005c8a;--tds-chip-fg-hover: #004e75;--tds-chip-fg-pressed: #00496e;--tds-chip-icon: #005c8a;--tds-chip-icon-hover: #004e75;--tds-chip-icon-pressed: #00496e;--tds-chip-border: #005c8a;--tds-chip-border-hover: #004e75;--tds-chip-border-pressed: #00496e}.tds-chip--intent-secondary.tds-chip--toggle-on{--tds-chip-bg: #ffffff;--tds-chip-bg-hover: #d9d9d9;--tds-chip-bg-pressed: #cccccc;--tds-chip-fg: #1a1a1a;--tds-chip-fg-hover: #161616;--tds-chip-fg-pressed: #151515;--tds-chip-icon: #1a1a1a;--tds-chip-icon-hover: #161616;--tds-chip-icon-pressed: #151515;--tds-chip-border: #8c8c8c;--tds-chip-border-hover: #777777;--tds-chip-border-pressed: #707070}.tds-chip--intent-secondary.tds-chip--toggle-off{--tds-chip-bg: #f2f2f2;--tds-chip-bg-hover: #cecece;--tds-chip-bg-pressed: #c2c2c2;--tds-chip-fg: #404040;--tds-chip-fg-hover: #363636;--tds-chip-fg-pressed: #333333;--tds-chip-icon: #404040;--tds-chip-icon-hover: #363636;--tds-chip-icon-pressed: #333333}.tds-chip--channel-true.tds-chip--toggle-on{--tds-chip-bg: #404040;--tds-chip-bg-hover: #404040;--tds-chip-bg-pressed: #404040;--tds-chip-fg: #ffffff;--tds-chip-fg-hover: #e6e6e6;--tds-chip-fg-pressed: #e6e6e6}.tds-chip--channel-secondary.tds-chip--toggle-on{--tds-chip-bg: #ffffff;--tds-chip-bg-hover: #e6e6e6;--tds-chip-bg-pressed: #e6e6e6;--tds-chip-fg: #404040;--tds-chip-fg-hover: #1a1a1a;--tds-chip-fg-pressed: #1a1a1a;--tds-chip-icon: #404040;--tds-chip-icon-hover: #1a1a1a;--tds-chip-icon-pressed: #1a1a1a;--tds-chip-border: #404040;--tds-chip-border-hover: #404040;--tds-chip-border-pressed: #404040}
|