@times-design-system/components-wordpress 1.9.0 → 1.11.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/block.json +1 -0
- package/dist/blocks/ad-container/style.css +1 -30
- package/dist/blocks/ad-container/style.scss +70 -0
- package/dist/blocks/button/block.json +68 -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 +23 -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/block.json +1 -0
- package/dist/blocks/dialog-box/style.css +1 -23
- package/dist/blocks/dialog-box/style.scss +113 -0
- package/dist/blocks/divider/block.json +1 -0
- package/dist/blocks/divider/style.css +1 -37
- package/dist/blocks/divider/style.scss +40 -0
- package/dist/blocks/icon/block.json +11 -1
- package/dist/blocks/icon/style.css +1 -23
- package/dist/blocks/icon/style.scss +10 -0
- package/dist/blocks/icon-button/block.json +42 -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/block.json +1 -0
- package/dist/blocks/input/style.css +1 -67
- package/dist/blocks/input/style.scss +72 -0
- package/dist/blocks/input-helper-message/block.json +1 -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 +87 -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/block.json +1 -0
- package/dist/blocks/tab/style.css +1 -152
- package/dist/blocks/tab/style.scss +159 -0
- package/dist/blocks/tab-group/block.json +1 -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 +47 -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/block.json +1 -0
- package/dist/blocks/text/style.css +1 -7
- package/dist/blocks/text/style.scss +11 -0
- package/dist/blocks/toast/block.json +1 -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 +421 -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 +421 -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,159 @@
|
|
|
1
|
+
/* Tab Block Frontend Styles */
|
|
2
|
+
/* Uses SCSS variables from @times-design-system/theme-scss */
|
|
3
|
+
|
|
4
|
+
@import '@times-design-system/theme-scss/src/palettes/core-light.scss';
|
|
5
|
+
@import '@times-design-system/theme-scss/src/tds-layout.scss';
|
|
6
|
+
@import '@times-design-system/theme-scss/src/tds-typography.scss';
|
|
7
|
+
|
|
8
|
+
.tds-tab {
|
|
9
|
+
--tds-tab-bg: transparent;
|
|
10
|
+
--tds-tab-bg-hover: #{$surface-channel-100};
|
|
11
|
+
--tds-tab-bg-pressed: #{$surface-channel-100};
|
|
12
|
+
--tds-tab-fg: #{$text-primary};
|
|
13
|
+
--tds-tab-fg-hover: #{$text-secondary};
|
|
14
|
+
--tds-tab-fg-pressed: #{$text-secondary};
|
|
15
|
+
--tds-tab-icon: #{$text-primary};
|
|
16
|
+
--tds-tab-icon-hover: #{$text-secondary};
|
|
17
|
+
--tds-tab-icon-pressed: #{$text-secondary};
|
|
18
|
+
--tds-tab-selected-border: #{$text-primary};
|
|
19
|
+
--tds-tab-focus-ring: #{$text-tertiary};
|
|
20
|
+
|
|
21
|
+
position: relative;
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
gap: $spacing-05;
|
|
26
|
+
border: 0;
|
|
27
|
+
border-bottom: 2px solid transparent;
|
|
28
|
+
background-color: var(--tds-tab-bg);
|
|
29
|
+
color: var(--tds-tab-fg);
|
|
30
|
+
font-family: Roboto;
|
|
31
|
+
font-weight: 500;
|
|
32
|
+
line-height: 1.25;
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.tds-tab:hover:not(:disabled) {
|
|
39
|
+
background-color: var(--tds-tab-bg-hover);
|
|
40
|
+
color: var(--tds-tab-fg-hover);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.tds-tab:active:not(:disabled) {
|
|
44
|
+
background-color: var(--tds-tab-bg-pressed);
|
|
45
|
+
color: var(--tds-tab-fg-pressed);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.tds-tab:focus-visible {
|
|
49
|
+
outline: none;
|
|
50
|
+
background-color: var(--tds-tab-bg-hover);
|
|
51
|
+
color: var(--tds-tab-fg-hover);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.tds-tab:focus-visible::after {
|
|
55
|
+
content: '';
|
|
56
|
+
position: absolute;
|
|
57
|
+
inset: calc(#{$spacing-02} * -1);
|
|
58
|
+
border: $spacing-01 solid var(--tds-tab-focus-ring);
|
|
59
|
+
border-radius: $spacing-02;
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.tds-tab:disabled {
|
|
64
|
+
background-color: $interactive-disabled-b;
|
|
65
|
+
color: $interactive-disabled-a;
|
|
66
|
+
cursor: not-allowed;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.tds-tab--state-hover:not(:disabled) {
|
|
70
|
+
background-color: var(--tds-tab-bg-hover);
|
|
71
|
+
color: var(--tds-tab-fg-hover);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.tds-tab--state-pressed:not(:disabled) {
|
|
75
|
+
background-color: var(--tds-tab-bg-pressed);
|
|
76
|
+
color: var(--tds-tab-fg-pressed);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.tds-tab--state-focus:not(:disabled) {
|
|
80
|
+
background-color: var(--tds-tab-bg-hover);
|
|
81
|
+
color: var(--tds-tab-fg-hover);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.tds-tab--state-focus:not(:disabled)::after {
|
|
85
|
+
content: '';
|
|
86
|
+
position: absolute;
|
|
87
|
+
inset: calc(#{$spacing-02} * -1);
|
|
88
|
+
border: $spacing-01 solid var(--tds-tab-focus-ring);
|
|
89
|
+
border-radius: $spacing-02;
|
|
90
|
+
pointer-events: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.tds-tab--state-disabled {
|
|
94
|
+
background-color: $interactive-disabled-b;
|
|
95
|
+
color: $interactive-disabled-a;
|
|
96
|
+
cursor: not-allowed;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.tds-tab--active-true {
|
|
100
|
+
border-bottom-color: var(--tds-tab-selected-border);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.tds-tab--active-false {
|
|
104
|
+
border-bottom-color: transparent;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.tds-tab--size-medium {
|
|
108
|
+
min-height: $spacing-17;
|
|
109
|
+
padding: 0 $spacing-07;
|
|
110
|
+
font-size: $fontSize030;
|
|
111
|
+
line-height: 1.125;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.tds-tab--size-large {
|
|
115
|
+
min-height: $spacing-18;
|
|
116
|
+
padding: 0 $spacing-09;
|
|
117
|
+
font-size: $fontSize040;
|
|
118
|
+
line-height: 1.125;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.tds-tab__label {
|
|
122
|
+
display: inline-flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
justify-content: center;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.tds-tab__icon {
|
|
128
|
+
display: inline-flex;
|
|
129
|
+
align-items: center;
|
|
130
|
+
justify-content: center;
|
|
131
|
+
color: var(--tds-tab-icon);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.tds-tab:hover:not(:disabled) .tds-tab__icon,
|
|
135
|
+
.tds-tab:focus-visible .tds-tab__icon,
|
|
136
|
+
.tds-tab--state-hover:not(:disabled) .tds-tab__icon,
|
|
137
|
+
.tds-tab--state-focus:not(:disabled) .tds-tab__icon {
|
|
138
|
+
color: var(--tds-tab-icon-hover);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.tds-tab:active:not(:disabled) .tds-tab__icon,
|
|
142
|
+
.tds-tab--state-pressed:not(:disabled) .tds-tab__icon {
|
|
143
|
+
color: var(--tds-tab-icon-pressed);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.tds-tab:disabled .tds-tab__icon,
|
|
147
|
+
.tds-tab--state-disabled .tds-tab__icon {
|
|
148
|
+
color: $interactive-disabled-a;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.tds-tab--size-medium .tds-tab__icon {
|
|
152
|
+
width: $spacing-09;
|
|
153
|
+
height: $spacing-09;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.tds-tab--size-large .tds-tab__icon {
|
|
157
|
+
width: $spacing-11;
|
|
158
|
+
height: $spacing-11;
|
|
159
|
+
}
|
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Styles for TabGroup Block
|
|
3
|
-
*
|
|
4
|
-
* Reference: packages/components-react/src/TabGroup/
|
|
5
|
-
* Token Reference: packages/tokens/data/resolved-hexes.json
|
|
6
|
-
*
|
|
7
|
-
* TODO: Adapt styles from React component
|
|
8
|
-
* - Copy relevant CSS from React component
|
|
9
|
-
* - Map CSS custom properties to resolved hex values
|
|
10
|
-
* - Use BEM naming: .tds-tab-group--{modifier}
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
.tds-tab-group {
|
|
14
|
-
/* TODO: Add component styles here */
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.tds-tab-group--focus {
|
|
18
|
-
/* TODO: Add focus state styles */
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.tds-tab-group--disabled {
|
|
22
|
-
/* TODO: Add disabled state styles */
|
|
23
|
-
}
|
|
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-tab-group{display:inline-flex;align-items:stretch;gap:0;border-bottom:1px solid #b3b3b3}.tds-tab-group--behaviour-hug{display:inline-flex;width:auto}.tds-tab-group--behaviour-fill{display:flex;width:100%}.tds-tab-group--behaviour-fill>.tds-tab{flex:1 1 0;min-width:0}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styles for TabGroup Block
|
|
3
|
+
* Uses SCSS variables from @times-design-system/theme-scss
|
|
4
|
+
*
|
|
5
|
+
* Reference: packages/components-react/src/TabGroup/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
@import '@times-design-system/theme-scss/src/palettes/core-light.scss';
|
|
9
|
+
@import '@times-design-system/theme-scss/src/tds-layout.scss';
|
|
10
|
+
@import '@times-design-system/theme-scss/src/tds-typography.scss';
|
|
11
|
+
|
|
12
|
+
.tds-tab-group {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: stretch;
|
|
15
|
+
gap: 0;
|
|
16
|
+
border-bottom: 1px solid $border-primary;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.tds-tab-group--behaviour-hug {
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
width: auto;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.tds-tab-group--behaviour-fill {
|
|
25
|
+
display: flex;
|
|
26
|
+
width: 100%;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.tds-tab-group--behaviour-fill > .tds-tab {
|
|
30
|
+
flex: 1 1 0;
|
|
31
|
+
min-width: 0;
|
|
32
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
3
|
"apiVersion": 3,
|
|
4
|
-
"name": "tds/
|
|
5
|
-
"title": "
|
|
4
|
+
"name": "tds/tag",
|
|
5
|
+
"title": "Tag",
|
|
6
6
|
"category": "common",
|
|
7
7
|
"description": "Badge or status indicator component",
|
|
8
|
-
"icon": "
|
|
8
|
+
"icon": "tag",
|
|
9
9
|
"supports": {
|
|
10
10
|
"html": false,
|
|
11
11
|
"spacing": {
|
|
@@ -18,20 +18,30 @@
|
|
|
18
18
|
"type": "string",
|
|
19
19
|
"default": ""
|
|
20
20
|
},
|
|
21
|
-
"content": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"default": ""
|
|
24
|
-
},
|
|
25
21
|
"intent": {
|
|
26
22
|
"type": "string",
|
|
27
23
|
"default": "secondary",
|
|
28
|
-
"enum": ["primary", "secondary", "
|
|
24
|
+
"enum": ["primary", "secondary", "tertiary"]
|
|
29
25
|
},
|
|
30
26
|
"size": {
|
|
31
27
|
"type": "string",
|
|
32
28
|
"default": "medium",
|
|
33
29
|
"enum": ["small", "medium", "large"]
|
|
34
30
|
},
|
|
31
|
+
"callout": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"default": false,
|
|
34
|
+
"description": "Applies a callout style to the tag"
|
|
35
|
+
},
|
|
36
|
+
"channel": {
|
|
37
|
+
"type": "boolean",
|
|
38
|
+
"default": false
|
|
39
|
+
},
|
|
40
|
+
"ariaLabel": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"default": "",
|
|
43
|
+
"description": "ARIA label for accessibility"
|
|
44
|
+
},
|
|
35
45
|
"iconLeft": {
|
|
36
46
|
"type": "string",
|
|
37
47
|
"default": "",
|
|
@@ -42,14 +52,10 @@
|
|
|
42
52
|
"default": "",
|
|
43
53
|
"description": "Icon on the right with variant prefix (e.g., 'outlined_check')"
|
|
44
54
|
},
|
|
45
|
-
"ariaLabel": {
|
|
46
|
-
"type": "string",
|
|
47
|
-
"default": ""
|
|
48
|
-
},
|
|
49
55
|
"classes": {
|
|
50
56
|
"type": "string",
|
|
51
57
|
"default": "",
|
|
52
|
-
"description": "Additional CSS classes applied to the rendered
|
|
58
|
+
"description": "Additional CSS classes applied to the rendered tag element"
|
|
53
59
|
},
|
|
54
60
|
"dataAttributes": {
|
|
55
61
|
"type": "object",
|
|
@@ -58,6 +64,33 @@
|
|
|
58
64
|
}
|
|
59
65
|
},
|
|
60
66
|
"example": {},
|
|
67
|
+
"style": "file:./style.css",
|
|
61
68
|
"script": "times-design-system",
|
|
62
|
-
"editorScript": "times-design-system"
|
|
69
|
+
"editorScript": "times-design-system",
|
|
70
|
+
"preview": {
|
|
71
|
+
"combinations": [
|
|
72
|
+
{ "label": "Primary", "intent": "primary", "size": "small" },
|
|
73
|
+
{ "label": "Secondary", "intent": "secondary", "size": "medium" },
|
|
74
|
+
{ "label": "Tertiary", "intent": "tertiary", "size": "large" },
|
|
75
|
+
{
|
|
76
|
+
"label": "Callout",
|
|
77
|
+
"intent": "primary",
|
|
78
|
+
"callout": true,
|
|
79
|
+
"size": "medium",
|
|
80
|
+
"iconLeft": "filled_check"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"label": "Channel",
|
|
84
|
+
"intent": "primary",
|
|
85
|
+
"channel": true,
|
|
86
|
+
"size": "medium"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"label": "With Icon",
|
|
90
|
+
"intent": "primary",
|
|
91
|
+
"iconLeft": "filled_check",
|
|
92
|
+
"size": "large"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
63
96
|
}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useBlockProps,
|
|
3
|
-
RichText,
|
|
4
|
-
InspectorControls
|
|
5
|
-
} from '@wordpress/block-editor';
|
|
1
|
+
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
|
|
6
2
|
import { PanelBody, SelectControl, TextControl } from '@wordpress/components';
|
|
7
3
|
|
|
8
4
|
const edit = ({ attributes, setAttributes }) => {
|
|
9
5
|
const {
|
|
10
6
|
label,
|
|
11
|
-
content,
|
|
12
7
|
intent,
|
|
13
8
|
size,
|
|
14
9
|
iconLeft,
|
|
@@ -20,16 +15,16 @@ const edit = ({ attributes, setAttributes }) => {
|
|
|
20
15
|
const blockProps = useBlockProps();
|
|
21
16
|
|
|
22
17
|
const buildClass = () => {
|
|
23
|
-
const classes = ['tds-
|
|
24
|
-
classes.push(`tds-
|
|
25
|
-
classes.push(`tds-
|
|
18
|
+
const classes = ['tds-tag'];
|
|
19
|
+
classes.push(`tds-tag--intent-${intent}`);
|
|
20
|
+
classes.push(`tds-tag--size-${size}`);
|
|
26
21
|
return classes.join(' ');
|
|
27
22
|
};
|
|
28
23
|
|
|
29
24
|
return (
|
|
30
25
|
<>
|
|
31
26
|
<InspectorControls>
|
|
32
|
-
<PanelBody title="
|
|
27
|
+
<PanelBody title="Tag Settings">
|
|
33
28
|
<TextControl
|
|
34
29
|
label="Label"
|
|
35
30
|
value={label}
|
|
@@ -79,7 +74,7 @@ const edit = ({ attributes, setAttributes }) => {
|
|
|
79
74
|
value={classes}
|
|
80
75
|
onChange={(val) => setAttributes({ classes: val })}
|
|
81
76
|
placeholder="class-name-1 class-name-2"
|
|
82
|
-
help="Space-separated CSS classes added to the
|
|
77
|
+
help="Space-separated CSS classes added to the tag element"
|
|
83
78
|
/>
|
|
84
79
|
|
|
85
80
|
<p style={{ fontSize: '12px', color: '#666', marginTop: '8px' }}>
|
|
@@ -90,15 +85,9 @@ const edit = ({ attributes, setAttributes }) => {
|
|
|
90
85
|
</PanelBody>
|
|
91
86
|
</InspectorControls>
|
|
92
87
|
<div {...blockProps} className={buildClass()} aria-label={ariaLabel}>
|
|
93
|
-
{label && <div className="tds-
|
|
94
|
-
{iconLeft && <span className="tds-
|
|
95
|
-
<
|
|
96
|
-
value={content}
|
|
97
|
-
onChange={(val) => setAttributes({ content: val })}
|
|
98
|
-
placeholder="Flag content"
|
|
99
|
-
className="tds-flag__content"
|
|
100
|
-
/>
|
|
101
|
-
{iconRight && <span className="tds-flag__icon-right">{iconRight}</span>}
|
|
88
|
+
{label && <div className="tds-tag__label">{label}</div>}
|
|
89
|
+
{iconLeft && <span className="tds-tag__icon-left">{iconLeft}</span>}
|
|
90
|
+
{iconRight && <span className="tds-tag__icon-right">{iconRight}</span>}
|
|
102
91
|
</div>
|
|
103
92
|
</>
|
|
104
93
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { registerBlockType } from '@wordpress/blocks';
|
|
2
2
|
import metadata from './block.json';
|
|
3
|
-
import edit from './edit';
|
|
4
|
-
import save from './save';
|
|
3
|
+
import edit from './edit.js';
|
|
4
|
+
import save from './save.js';
|
|
5
5
|
|
|
6
6
|
registerBlockType(metadata.name, {
|
|
7
7
|
...metadata,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Tag Block Render Callback
|
|
4
4
|
*
|
|
5
|
-
* Renders the
|
|
5
|
+
* Renders the Tag block on the frontend.
|
|
6
6
|
*
|
|
7
7
|
* @package TimesDesignSystem\ComponentsWordPress
|
|
8
8
|
* @var array $attributes Block attributes
|
|
9
|
-
* @var string $content Block content
|
|
10
9
|
* @var WP_Block $block Block instance
|
|
11
10
|
*/
|
|
12
11
|
|
|
@@ -14,13 +13,14 @@ require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
|
14
13
|
require_once __DIR__ . '/../../utils/render-icon.php';
|
|
15
14
|
|
|
16
15
|
$label = isset($attributes['label']) ? sanitize_text_field($attributes['label']) : '';
|
|
17
|
-
$
|
|
18
|
-
$
|
|
19
|
-
$size = isset($attributes['size']) ? sanitize_text_field($attributes['size']) : '';
|
|
16
|
+
$intent = isset($attributes['intent']) ? sanitize_text_field($attributes['intent']) : 'primary';
|
|
17
|
+
$size = isset($attributes['size']) ? sanitize_text_field($attributes['size']) : 'medium';
|
|
20
18
|
$icon_left = isset($attributes['iconLeft']) ? sanitize_text_field($attributes['iconLeft']) : '';
|
|
21
19
|
$icon_right = isset($attributes['iconRight']) ? sanitize_text_field($attributes['iconRight']) : '';
|
|
20
|
+
$callout = isset($attributes['callout']) ? (bool) $attributes['callout'] : false;
|
|
21
|
+
$channel = isset($attributes['channel']) ? (bool) $attributes['channel'] : false;
|
|
22
22
|
|
|
23
|
-
// Derive icon size from
|
|
23
|
+
// Derive icon size from tag size
|
|
24
24
|
$icon_size_map = [
|
|
25
25
|
'small' => 'xsmall',
|
|
26
26
|
'medium' => 'small',
|
|
@@ -31,15 +31,21 @@ $aria_label = isset($attributes['ariaLabel']) ? sanitize_text_field($attributes[
|
|
|
31
31
|
$element_class_name = isset($attributes['classes']) ? sanitize_text_field($attributes['classes']) : '';
|
|
32
32
|
|
|
33
33
|
// Sanitize and prepare data-* attributes
|
|
34
|
-
$sanitized_data_attributes = tds_sanitize_data_attributes($attributes['dataAttributes'] ?? [], '
|
|
34
|
+
$sanitized_data_attributes = tds_sanitize_data_attributes($attributes['dataAttributes'] ?? [], 'tag', $attributes);
|
|
35
35
|
$data_attrs_html = '';
|
|
36
36
|
foreach ($sanitized_data_attributes as $attr_name => $attr_value) {
|
|
37
37
|
$data_attrs_html .= ' ' . esc_attr($attr_name) . '="' . esc_attr($attr_value) . '"';
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
$classes = ['tds-
|
|
41
|
-
$classes[] = 'tds-
|
|
42
|
-
$classes[] = 'tds-
|
|
40
|
+
$classes = ['tds-tag'];
|
|
41
|
+
$classes[] = 'tds-tag--intent-' . $intent;
|
|
42
|
+
$classes[] = 'tds-tag--size-' . $size;
|
|
43
|
+
if ($callout) {
|
|
44
|
+
$classes[] = 'tds-tag--callout';
|
|
45
|
+
}
|
|
46
|
+
if ($channel) {
|
|
47
|
+
$classes[] = 'tds-tag--channel';
|
|
48
|
+
}
|
|
43
49
|
if ($element_class_name) {
|
|
44
50
|
$classes[] = $element_class_name;
|
|
45
51
|
}
|
|
@@ -52,16 +58,15 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)
|
|
|
52
58
|
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
53
59
|
<?php echo wp_kses_post($data_attrs_html); ?>
|
|
54
60
|
>
|
|
61
|
+
<?php if ($icon_left) : ?>
|
|
62
|
+
<span class="tds-tag__icon tds-tag__icon--left"><?php echo wp_kses_post(tds_render_icon($icon_left, $icon_size)); ?></span>
|
|
63
|
+
<?php endif; ?>
|
|
55
64
|
<?php if ($label) : ?>
|
|
56
|
-
<div class="tds-
|
|
57
|
-
<?php if ($icon_left) : ?>
|
|
58
|
-
<span class="tds-flag__icon tds-flag__icon--left"><?php echo wp_kses_post(tds_render_icon($icon_left, $icon_size)); ?></span>
|
|
59
|
-
<?php endif; ?>
|
|
65
|
+
<div class="tds-tag__label">
|
|
60
66
|
<?php echo wp_kses_post($label); ?>
|
|
61
|
-
<?php if ($icon_right) : ?>
|
|
62
|
-
<span class="tds-flag__icon tds-flag__icon--right"><?php echo wp_kses_post(tds_render_icon($icon_right, $icon_size)); ?></span>
|
|
63
|
-
<?php endif; ?>
|
|
64
67
|
</div>
|
|
65
68
|
<?php endif; ?>
|
|
66
|
-
|
|
69
|
+
<?php if ($icon_right) : ?>
|
|
70
|
+
<span class="tds-tag__icon tds-tag__icon--right"><?php echo wp_kses_post(tds_render_icon($icon_right, $icon_size)); ?></span>
|
|
71
|
+
<?php endif; ?>
|
|
67
72
|
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useBlockProps, RichText } from '@wordpress/block-editor';
|
|
2
|
+
|
|
3
|
+
const save = ({ attributes }) => {
|
|
4
|
+
const { label, intent, size, iconLeft, iconRight, ariaLabel } = attributes;
|
|
5
|
+
const blockProps = useBlockProps.save();
|
|
6
|
+
|
|
7
|
+
const buildClass = () => {
|
|
8
|
+
const classes = ['tds-tag'];
|
|
9
|
+
classes.push(`tds-tag--intent-${intent}`);
|
|
10
|
+
classes.push(`tds-tag--size-${size}`);
|
|
11
|
+
return classes.join(' ');
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div {...blockProps} className={buildClass()} aria-label={ariaLabel}>
|
|
16
|
+
{label && <div className="tds-tag__label">{label}</div>}
|
|
17
|
+
{iconLeft && <span className="tds-tag__icon-left">{iconLeft}</span>}
|
|
18
|
+
{iconRight && <span className="tds-tag__icon-right">{iconRight}</span>}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default save;
|
|
@@ -0,0 +1 @@
|
|
|
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-tag{--tds-tag-bg: #000000;--tds-tag-fg: #ffffff;display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:19px;min-width:42px;padding:4px 6px;border-radius:2px;background-color:var(--tds-tag-bg);color:var(--tds-tag-fg);font:500 var(--font-size020)/1.125 Times Roboto;text-transform:uppercase;white-space:nowrap;box-sizing:border-box}.tds-tag--size-small{padding:2px 6px;font:500 var(--font-size010)/1.125 Times Roboto;gap:2px}.tds-tag--size-large{padding:8px;font:500 var(--font-size030)/1.125 Times Roboto}.tds-tag--intent-primary{--tds-tag-bg: #000000;--tds-tag-fg: #ffffff}.tds-tag--intent-secondary{--tds-tag-bg: #d9d9d9;--tds-tag-fg: #1a1a1a}.tds-tag--intent-tertiary{--tds-tag-bg: transparent;--tds-tag-fg: #1a1a1a}.tds-tag--callout{--tds-tag-bg: #b20908;--tds-tag-fg: #ffffff}.tds-tag--intent-secondary.tds-tag--callout{--tds-tag-bg: #ffefef;--tds-tag-fg: #b20908}.tds-tag--intent-tertiary.tds-tag--callout{--tds-tag-bg: transparent;--tds-tag-fg: #b20908}.tds-tag--channel{--tds-tag-bg: #4d4d4d;--tds-tag-fg: #ffffff}.tds-tag--intent-secondary.tds-tag--channel{--tds-tag-bg: #e6e6e6;--tds-tag-fg: #4d4d4d}.tds-tag--intent-tertiary.tds-tag--channel{--tds-tag-bg: transparent;--tds-tag-fg: #4d4d4d}.tds-tag__label{display:inline-flex;align-items:center;padding:0 2px}.tds-tag--size-large .tds-tag__label{padding:0 4px}.tds-tag__icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px}.tds-tag--size-small .tds-tag__icon{width:12px;height:12px}.tds-tag__icon svg{width:100%;height:100%}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* Tag Block Frontend Styles (Tag Component) */
|
|
2
|
+
/* Uses SCSS variables from @times-design-system/theme-scss */
|
|
3
|
+
/* Maintains styling parity with React Tag component */
|
|
4
|
+
|
|
5
|
+
@import '@times-design-system/theme-scss/src/palettes/core-light.scss';
|
|
6
|
+
@import '@times-design-system/theme-scss/src/tds-layout.scss';
|
|
7
|
+
@import '@times-design-system/theme-scss/src/tds-typography.scss';
|
|
8
|
+
|
|
9
|
+
.tds-tag {
|
|
10
|
+
--tds-tag-bg: #{$tag-primary-fill};
|
|
11
|
+
--tds-tag-fg: #{$tag-primary-text};
|
|
12
|
+
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
gap: $spacing-03;
|
|
17
|
+
min-height: 19px;
|
|
18
|
+
min-width: 42px;
|
|
19
|
+
padding: $spacing-03 $spacing-04;
|
|
20
|
+
border-radius: $border-radius-50;
|
|
21
|
+
background-color: var(--tds-tag-bg);
|
|
22
|
+
color: var(--tds-tag-fg);
|
|
23
|
+
@include utility-label-small;
|
|
24
|
+
text-transform: uppercase;
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.tds-tag--size-small {
|
|
30
|
+
padding: $spacing-01 $spacing-04;
|
|
31
|
+
@include utility-label-xsmall;
|
|
32
|
+
gap: $spacing-01;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.tds-tag--size-large {
|
|
36
|
+
padding: $spacing-05;
|
|
37
|
+
@include utility-label-medium;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Intent variants */
|
|
41
|
+
.tds-tag--intent-primary {
|
|
42
|
+
--tds-tag-bg: #{$tag-primary-fill};
|
|
43
|
+
--tds-tag-fg: #{$tag-primary-text};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.tds-tag--intent-secondary {
|
|
47
|
+
--tds-tag-bg: #{$tag-secondary-fill};
|
|
48
|
+
--tds-tag-fg: #{$tag-secondary-text};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.tds-tag--intent-tertiary {
|
|
52
|
+
--tds-tag-bg: transparent;
|
|
53
|
+
--tds-tag-fg: #{$tag-tertiary-text};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Callout modifier - overrides intent colors */
|
|
57
|
+
.tds-tag--callout {
|
|
58
|
+
--tds-tag-bg: #{$tag-callout-primary-fill};
|
|
59
|
+
--tds-tag-fg: #{$tag-callout-primary-text};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.tds-tag--intent-secondary.tds-tag--callout {
|
|
63
|
+
--tds-tag-bg: #{$tag-callout-secondary-fill};
|
|
64
|
+
--tds-tag-fg: #{$tag-callout-secondary-text};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.tds-tag--intent-tertiary.tds-tag--callout {
|
|
68
|
+
--tds-tag-bg: transparent;
|
|
69
|
+
--tds-tag-fg: #{$tag-callout-tertiary-text};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* Channel modifier - overrides intent and callout colors */
|
|
73
|
+
.tds-tag--channel {
|
|
74
|
+
--tds-tag-bg: #{$surface-channel-400};
|
|
75
|
+
--tds-tag-fg: #{$text-inverse};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.tds-tag--intent-secondary.tds-tag--channel {
|
|
79
|
+
--tds-tag-bg: #{$surface-channel-100};
|
|
80
|
+
--tds-tag-fg: #{$text-channel-primary};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.tds-tag--intent-tertiary.tds-tag--channel {
|
|
84
|
+
--tds-tag-bg: transparent;
|
|
85
|
+
--tds-tag-fg: #{$text-channel-primary};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* Label and icon styling */
|
|
89
|
+
.tds-tag__label {
|
|
90
|
+
display: inline-flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
padding: 0 $spacing-01;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.tds-tag--size-large .tds-tag__label {
|
|
96
|
+
padding: 0 $spacing-03;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.tds-tag__icon {
|
|
100
|
+
display: inline-flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
width: $spacing-09;
|
|
104
|
+
height: $spacing-09;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.tds-tag--size-small .tds-tag__icon {
|
|
108
|
+
width: $spacing-07;
|
|
109
|
+
height: $spacing-07;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.tds-tag__icon svg {
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
}
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/* Using resolved design token values for self-contained styling */
|
|
3
|
-
/* Text component is typography-based, minimal CSS needed */
|
|
4
|
-
|
|
5
|
-
.tds-text {
|
|
6
|
-
/* Base typography handled by design tokens and parent context */
|
|
7
|
-
}
|
|
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}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* Text Block Frontend Styles */
|
|
2
|
+
/* Uses SCSS variables from @times-design-system/theme-scss */
|
|
3
|
+
/* Text component is typography-based, minimal CSS needed */
|
|
4
|
+
|
|
5
|
+
@import '@times-design-system/theme-scss/src/palettes/core-light.scss';
|
|
6
|
+
@import '@times-design-system/theme-scss/src/tds-layout.scss';
|
|
7
|
+
@import '@times-design-system/theme-scss/src/tds-typography.scss';
|
|
8
|
+
|
|
9
|
+
.tds-text {
|
|
10
|
+
/* Base typography handled by design tokens and parent context */
|
|
11
|
+
}
|