@nycds/button 0.4.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/CHANGELOG.md +184 -0
- package/LICENSE +674 -0
- package/README.org +64 -0
- package/css.org +344 -0
- package/dist/button-aem.css +1074 -0
- package/dist/button-aem.min.css +1 -0
- package/dist/button.css +682 -0
- package/dist/button.min.css +1 -0
- package/package.json +16 -0
- package/postcss.config.js +1 -0
- package/src/css/aem/index.css +86 -0
- package/src/css/index.css +40 -0
- package/src/css/mixins.css +380 -0
- package/src/js/BackToTop.js +90 -0
- package/src/js/NYCBackToTop.js +90 -0
- package/src/js/aem/index.js +1 -0
- package/src/js/index.js +1 -0
- package/tests/back-to-top.spec.js +16 -0
- package/tests/index.html +20 -0
package/README.org
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#+title: Button
|
|
2
|
+
|
|
3
|
+
Buttons encourage users to take an action. They use text or icons to communicate what will happen after the user engages with the button. They are one of two action components, along with links.
|
|
4
|
+
|
|
5
|
+
* Primary button :docs-site:
|
|
6
|
+
|
|
7
|
+
The primary button can be utilized with a ~button~ or ~a~ element, with the following:
|
|
8
|
+
- *Class*: ~nyc-button~
|
|
9
|
+
- *Attribute*: ~data-variant="primary"~
|
|
10
|
+
|
|
11
|
+
#+results: primary-button-example
|
|
12
|
+
|
|
13
|
+
#+name: primary-button-example
|
|
14
|
+
#+begin_src html :exports both :results replace html
|
|
15
|
+
<div class="code-examples">
|
|
16
|
+
<button class="nyc-button">Default</button>
|
|
17
|
+
<button class="nyc-button" data-variant="primary" disabled>Disabled</button>
|
|
18
|
+
<a href="#" class="nyc-button" data-variant="primary">Link button</a>
|
|
19
|
+
</div>
|
|
20
|
+
#+end_src
|
|
21
|
+
|
|
22
|
+
* Secondary button :docs-site:
|
|
23
|
+
|
|
24
|
+
The secondary button can be utilized with a ~button~ or ~a~ element, with the following:
|
|
25
|
+
- *Class*: ~nyc-button~
|
|
26
|
+
- *Attribute*: ~data-variant="secondary"~
|
|
27
|
+
|
|
28
|
+
#+results: secondary-button-example
|
|
29
|
+
|
|
30
|
+
#+name: secondary-button-example
|
|
31
|
+
#+begin_src html :exports both :results replace html
|
|
32
|
+
<div class="code-examples">
|
|
33
|
+
<button class="nyc-button" data-variant="secondary">Default</button>
|
|
34
|
+
<button class="nyc-button" data-variant="secondary" disabled>Disabled</button>
|
|
35
|
+
<a href="#" class="nyc-button" data-variant="secondary">Link button</a>
|
|
36
|
+
</div>
|
|
37
|
+
#+end_src
|
|
38
|
+
|
|
39
|
+
* Icon button :docs-site:
|
|
40
|
+
|
|
41
|
+
The icon button can be utilized with a ~button~ or ~a~ element, with the following attributes:
|
|
42
|
+
- *Class*: ~nyc-button~
|
|
43
|
+
- *Attribute*: ~data-variant="icon"~
|
|
44
|
+
- *Icon element*: An icon element should be placed inside the button or link, using an icon font class enabled in the icons package (The package draws from the [[https://icon-sets.iconify.design/ph/][Iconify: Phosphor Iconset]]).
|
|
45
|
+
|
|
46
|
+
#+results: icon-button-example
|
|
47
|
+
|
|
48
|
+
#+name: icon-button-example
|
|
49
|
+
#+begin_src html :exports both :results replace html
|
|
50
|
+
<div class="code-examples">
|
|
51
|
+
<div>
|
|
52
|
+
<h4>Default</h4>
|
|
53
|
+
<button type="button" class="nyc-button" data-variant="icon" aria-label="Next"><i class="i-ph:caret-right-bold"></i></button>
|
|
54
|
+
</div>
|
|
55
|
+
<div>
|
|
56
|
+
<h4>Disabled</h4>
|
|
57
|
+
<button type="button" class="nyc-button" data-variant="icon" aria-label="Next" disabled><i class="i-ph:caret-right-bold"></i></button>
|
|
58
|
+
</div>
|
|
59
|
+
<div>
|
|
60
|
+
<h4>Link Button</h4>
|
|
61
|
+
<a href="#" class="nyc-button" data-variant="icon" aria-label="Next"><i class="i-ph:caret-right-bold"></i></a>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
#+end_src
|
package/css.org
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
#+title: Button
|
|
2
|
+
|
|
3
|
+
Buttons encourage users to take an action. They use text or icons to communicate what will happen after the user engages with the button. They are one of two action components, along with links.
|
|
4
|
+
|
|
5
|
+
** Examples
|
|
6
|
+
|
|
7
|
+
#+results: button-basic-example
|
|
8
|
+
|
|
9
|
+
#+name: button-basic-example
|
|
10
|
+
#+begin_src html :exports both :results replace html
|
|
11
|
+
<a href="#" class="button">Default button</a>
|
|
12
|
+
<a href="#" class="button" data-variant="primary">Primary button</a>
|
|
13
|
+
<a href="#" class="button">
|
|
14
|
+
<span>Button with icon</span>
|
|
15
|
+
<i class="i-ri:arrow-right-line"></i>
|
|
16
|
+
</a>
|
|
17
|
+
|
|
18
|
+
#+end_src
|
|
19
|
+
|
|
20
|
+
** Custom properties
|
|
21
|
+
|
|
22
|
+
Use these custom properties in your theme to override default styling
|
|
23
|
+
|
|
24
|
+
| Property | Default |
|
|
25
|
+
|-------------------------------+--------------|
|
|
26
|
+
| --nyc-cmp-button-color | currentColor |
|
|
27
|
+
| --nyc-cmp-button-background | white |
|
|
28
|
+
| --nyc-cmp-button-border-width | 2px |
|
|
29
|
+
| --nyc-cmp-button-border-color | grey |
|
|
30
|
+
| --nyc-cmp-button-shadow | none |
|
|
31
|
+
| --nyc-cmp-button-padding | .75rem |
|
|
32
|
+
|
|
33
|
+
** Base styles
|
|
34
|
+
|
|
35
|
+
The =button= CSS class implements the custom properties and other
|
|
36
|
+
default styles.
|
|
37
|
+
|
|
38
|
+
*** Mixin
|
|
39
|
+
|
|
40
|
+
#+begin_src css :noweb-ref mixins-base
|
|
41
|
+
@define-mixin button {
|
|
42
|
+
--_background: var(--nyc-cmp-button-background, hsl(0 0% 100%));
|
|
43
|
+
--_background-hover: var(--nyc-cmp-button-background-hover, hsl(0 0% 100%));
|
|
44
|
+
--_border-color: var(--nyc-cmp-button-border-color, hsl(0 0% 93%));
|
|
45
|
+
--_border-color-hover: var(--nyc-cmp-button-border-color-hover, currentColor);
|
|
46
|
+
--_border-width: var(--nyc-cmp-button-border-width, 2px);
|
|
47
|
+
--_border-radius: var(--nyc-cmp-button-border-radius, 0);
|
|
48
|
+
--_color: var(--nyc-cmp-button-color, hsl(0 0% 0%));
|
|
49
|
+
--_color-hover: var(--nyc-cmp-button-color-hover, hsl(0 0% 0%));
|
|
50
|
+
--_font-weight: var(--nyc-cmp-button-font-weight, 500);
|
|
51
|
+
--_font-size: var(--nyc-cmp-button-font-size, 1rem);
|
|
52
|
+
--_shadow: var(--nyc-cmp-button-shadow, none);
|
|
53
|
+
--_padding-block: var(--nyc-cmp-button-padding-block, 0.75rem);
|
|
54
|
+
--_padding-inline: var(--nyc-cmp-button-padding-inline, 0.75rem);
|
|
55
|
+
--_outline-color: var(--nyc-cmp-button-outline-color, inherit);
|
|
56
|
+
--_gap: var(--nyc-cmp-button-gap, 0.5rem);
|
|
57
|
+
|
|
58
|
+
appearance: none;
|
|
59
|
+
background-color: var(--_background);
|
|
60
|
+
border-color: var(--_border-color);
|
|
61
|
+
border-width: var(--_border-width);
|
|
62
|
+
border-style: solid;
|
|
63
|
+
border-radius: var(--_border-radius);
|
|
64
|
+
color: var(--_color);
|
|
65
|
+
padding: var(--_padding-block) var(--_padding-inline);
|
|
66
|
+
box-shadow: var(--_shadow);
|
|
67
|
+
text-decoration: none;
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
font-weight: var(--_font-weight);
|
|
70
|
+
font-size: var(--_font-size);
|
|
71
|
+
line-height: inherit;
|
|
72
|
+
display: inline-flex;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
gap: var(--_gap);
|
|
75
|
+
align-items: center;
|
|
76
|
+
transition: all 0.3s ease;
|
|
77
|
+
text-align: center;
|
|
78
|
+
|
|
79
|
+
/* & > :first-child:not(i) { */
|
|
80
|
+
/* flex-grow: 1; */
|
|
81
|
+
/* width: max-content; */
|
|
82
|
+
/* } */
|
|
83
|
+
|
|
84
|
+
/* & > i:last-child { */
|
|
85
|
+
/* flex-shrink: 0; */
|
|
86
|
+
/* margin-block: auto; */
|
|
87
|
+
/* font-size: 1.5rem; */
|
|
88
|
+
|
|
89
|
+
/* margin-inline-start: .5em; */
|
|
90
|
+
/* } */
|
|
91
|
+
|
|
92
|
+
&:hover {
|
|
93
|
+
background: var(--_background-hover);
|
|
94
|
+
color: var(--_color-hover);
|
|
95
|
+
border-color: var(--_border-color-hover);
|
|
96
|
+
text-decoration: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&:focus-visible {
|
|
100
|
+
outline: 3px solid var(--_outline-color);
|
|
101
|
+
outline-offset: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&[disabled] {
|
|
105
|
+
--nyc-cmp-button-color: var(--nyc-sys-color-on-disabled) !important;
|
|
106
|
+
--nyc-cmp-button-background: var(--nyc-sys-color-disabled) !important;
|
|
107
|
+
--nyc-cmp-button-border-color: var(--nyc-sys-color-on-disabled) !important;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* @media (width > 768px) { */
|
|
111
|
+
/* --_font-size: var(--nyc-cmp-button-font-size-max, 1rem); */
|
|
112
|
+
/* } */
|
|
113
|
+
}
|
|
114
|
+
#+end_src
|
|
115
|
+
|
|
116
|
+
*** Default class
|
|
117
|
+
|
|
118
|
+
#+begin_src css :noweb-ref default-base
|
|
119
|
+
.button,
|
|
120
|
+
.button:link,
|
|
121
|
+
.button:visited {
|
|
122
|
+
@mixin button;
|
|
123
|
+
}
|
|
124
|
+
#+end_src
|
|
125
|
+
|
|
126
|
+
*** AEM class
|
|
127
|
+
|
|
128
|
+
#+begin_src css :noweb-ref aem-base
|
|
129
|
+
.cmp-button,
|
|
130
|
+
.cmp-button:link,
|
|
131
|
+
.cmp-button:visited {
|
|
132
|
+
@mixin button;
|
|
133
|
+
}
|
|
134
|
+
#+end_src
|
|
135
|
+
|
|
136
|
+
** Variants
|
|
137
|
+
|
|
138
|
+
*** Primary
|
|
139
|
+
|
|
140
|
+
**** Mixin
|
|
141
|
+
|
|
142
|
+
#+begin_src css :noweb-ref mixins-primary
|
|
143
|
+
@define-mixin button-primary {
|
|
144
|
+
--nyc-cmp-button-background: var(--nyc-sys-color-primary);
|
|
145
|
+
--nyc-cmp-button-color: var(--nyc-sys-color-on-primary);
|
|
146
|
+
--nyc-cmp-button-border-color: var(--nyc-sys-color-primary);
|
|
147
|
+
--nyc-cmp-button-shadow: none;
|
|
148
|
+
&:hover {
|
|
149
|
+
--nyc-cmp-button-color-hover: var(--nyc-cmp-button-color);
|
|
150
|
+
--nyc-cmp-button-background-hover: var(--nyc-sys-color-primary-hover);
|
|
151
|
+
--nyc-cmp-button-border-color-hover: var(--nyc-sys-color-primary-hover);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
#+end_src
|
|
155
|
+
|
|
156
|
+
**** Default class
|
|
157
|
+
|
|
158
|
+
#+begin_src css :noweb-ref default-primary
|
|
159
|
+
.button[data-variant='primary'] {
|
|
160
|
+
@mixin button-primary;
|
|
161
|
+
}
|
|
162
|
+
#+end_src
|
|
163
|
+
|
|
164
|
+
**** AEM class
|
|
165
|
+
|
|
166
|
+
#+begin_src css :noweb-ref aem-primary
|
|
167
|
+
.cmp-button--primary .cmp-button {
|
|
168
|
+
@mixin button-primary;
|
|
169
|
+
}
|
|
170
|
+
#+end_src
|
|
171
|
+
|
|
172
|
+
*** Secondary
|
|
173
|
+
|
|
174
|
+
**** Mixin
|
|
175
|
+
|
|
176
|
+
#+begin_src css :noweb-ref mixins-secondary
|
|
177
|
+
@define-mixin button-secondary {
|
|
178
|
+
--nyc-cmp-button-background: var(--nyc-sys-color-secondary);
|
|
179
|
+
--nyc-cmp-button-color: var(--nyc-sys-color-on-secondary);
|
|
180
|
+
--nyc-cmp-button-border-color: var(--nyc-sys-color-border-base);
|
|
181
|
+
--nyc-cmp-button-shadow: none;
|
|
182
|
+
&:hover {
|
|
183
|
+
--nyc-cmp-button-color-hover: var(--nyc-sys-color-on-secondary-hover);
|
|
184
|
+
--nyc-cmp-button-border-color-hover: var(--nyc-sys-color-border-base);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
#+end_src
|
|
188
|
+
|
|
189
|
+
**** Default class
|
|
190
|
+
|
|
191
|
+
#+begin_src css :noweb-ref default-secondary
|
|
192
|
+
.button[data-variant='secondary'] {
|
|
193
|
+
@mixin button-secondary;
|
|
194
|
+
}
|
|
195
|
+
#+end_src
|
|
196
|
+
|
|
197
|
+
**** AEM class
|
|
198
|
+
|
|
199
|
+
#+begin_src css :noweb-ref aem-secondary
|
|
200
|
+
.cmp-button--secondary .cmp-button {
|
|
201
|
+
@mixin button-secondary;
|
|
202
|
+
}
|
|
203
|
+
#+end_src
|
|
204
|
+
|
|
205
|
+
*** Icon
|
|
206
|
+
|
|
207
|
+
**** Mixin
|
|
208
|
+
|
|
209
|
+
#+begin_src css :noweb-ref mixins-icon
|
|
210
|
+
@define-mixin button-icon {
|
|
211
|
+
--nyc-cmp-button-background: var(--nyc-sys-color-primary);
|
|
212
|
+
--nyc-cmp-button-color: var(--nyc-sys-color-on-primary);
|
|
213
|
+
--nyc-cmp-button-border-color: var(--nyc-sys-color-border-base);
|
|
214
|
+
--nyc-cmp-button-shadow: none;
|
|
215
|
+
--nyc-cmp-button-padding-inline: var(--nyc-cmp-button-padding-block);
|
|
216
|
+
&:hover {
|
|
217
|
+
--nyc-cmp-button-color-hover: var(--nyc-sys-color-on-primary-hover);
|
|
218
|
+
--nyc-cmp-button-border-color-hover: var(--nyc-sys-color-border-base);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
&[disabled] {
|
|
222
|
+
--nyc-cmp-button-color: var(--nyc-sys-color-on-disabled);
|
|
223
|
+
--nyc-cmp-button-background: var(--nyc-sys-color-disabled);
|
|
224
|
+
--nyc-cmp-button-border-color: var(--nyc-sys-color-on-disabled);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
#+end_src
|
|
228
|
+
|
|
229
|
+
**** Default class
|
|
230
|
+
|
|
231
|
+
#+begin_src css :noweb-ref default-icon
|
|
232
|
+
.button[data-variant='icon'] {
|
|
233
|
+
@mixin button-icon;
|
|
234
|
+
}
|
|
235
|
+
#+end_src
|
|
236
|
+
|
|
237
|
+
**** AEM class
|
|
238
|
+
|
|
239
|
+
#+begin_src css :noweb-ref aem-icon
|
|
240
|
+
.cmp-button--icon .cmp-button {
|
|
241
|
+
@mixin button-icon;
|
|
242
|
+
}
|
|
243
|
+
#+end_src
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
*** Full width
|
|
247
|
+
|
|
248
|
+
**** Mixin
|
|
249
|
+
|
|
250
|
+
#+begin_src css :noweb-ref full-width
|
|
251
|
+
@define-mixin button-full-width {
|
|
252
|
+
@media (max-width: 768px) {
|
|
253
|
+
&:first-child {
|
|
254
|
+
width: 100%;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
#+end_src
|
|
259
|
+
|
|
260
|
+
**** Default class
|
|
261
|
+
|
|
262
|
+
#+begin_src css :noweb-ref default-full-width
|
|
263
|
+
.button[data-variant='button-full-width'] {
|
|
264
|
+
@mixin button-full-width;
|
|
265
|
+
}
|
|
266
|
+
#+end_src
|
|
267
|
+
|
|
268
|
+
**** AEM class
|
|
269
|
+
|
|
270
|
+
#+begin_src css :noweb-ref aem-full-width
|
|
271
|
+
.cmp-button--full-width .cmp-button {
|
|
272
|
+
@mixin button-full-width;
|
|
273
|
+
}
|
|
274
|
+
#+end_src
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
*** Sizes
|
|
278
|
+
|
|
279
|
+
**** Mixin
|
|
280
|
+
|
|
281
|
+
#+begin_src css :noweb-ref mixins-sizes
|
|
282
|
+
@define-mixin button-sm {
|
|
283
|
+
--nyc-cmp-button-border-radius: var(--nyc-sys-radius-lg);
|
|
284
|
+
--nyc-cmp-button-padding-block: var(--nyc-sys-space-2xs);
|
|
285
|
+
--nyc-cmp-button-padding-inline: var(--nyc-sys-space-2xs);
|
|
286
|
+
--nyc-cmp-button-font-size: var(--nyc-sys-size-body-base);
|
|
287
|
+
--nyc-cmp-button-font-weight: 600;
|
|
288
|
+
}
|
|
289
|
+
#+end_src
|
|
290
|
+
|
|
291
|
+
**** Default class
|
|
292
|
+
|
|
293
|
+
#+begin_src css :noweb-ref default-sizes
|
|
294
|
+
.button[data-size='sm'] {
|
|
295
|
+
@mixin button-sm;
|
|
296
|
+
}
|
|
297
|
+
#+end_src
|
|
298
|
+
|
|
299
|
+
**** AEM class
|
|
300
|
+
|
|
301
|
+
#+begin_src css :noweb-ref aem-sizes
|
|
302
|
+
.cmp-button--sm .cmp-button {
|
|
303
|
+
@mixin button-sm;
|
|
304
|
+
}
|
|
305
|
+
#+end_src
|
|
306
|
+
|
|
307
|
+
** File exports :noexport:
|
|
308
|
+
|
|
309
|
+
*** Mixins
|
|
310
|
+
|
|
311
|
+
#+begin_src css :noweb yes
|
|
312
|
+
/* Generated from README.org - do not edit directly */
|
|
313
|
+
<<mixins-base>>
|
|
314
|
+
<<mixins-primary>>
|
|
315
|
+
<<mixins-secondary>>
|
|
316
|
+
<<mixins-icon>>
|
|
317
|
+
<<mixins-sizes>>
|
|
318
|
+
#+end_src
|
|
319
|
+
|
|
320
|
+
*** Default
|
|
321
|
+
|
|
322
|
+
#+begin_src css :noweb yes
|
|
323
|
+
/* Generated from README.org - do not edit directly */
|
|
324
|
+
@import './mixins.css';
|
|
325
|
+
|
|
326
|
+
<<default-base>>
|
|
327
|
+
<<default-primary>>
|
|
328
|
+
<<default-secondary>>
|
|
329
|
+
<<default-icon>>
|
|
330
|
+
<<default-sizes>>
|
|
331
|
+
#+end_src
|
|
332
|
+
|
|
333
|
+
*** AEM
|
|
334
|
+
|
|
335
|
+
#+begin_src css :noweb yes
|
|
336
|
+
/* Generated from README.org - do not edit directly */
|
|
337
|
+
@import '../mixins.css';
|
|
338
|
+
|
|
339
|
+
<<aem-base>>
|
|
340
|
+
<<aem-primary>>
|
|
341
|
+
<<aem-secondary>>
|
|
342
|
+
<<aem-icon>>
|
|
343
|
+
<<aem-sizes>>
|
|
344
|
+
#+end_src
|