@nycds/button 0.4.0 → 0.5.0-prerelease.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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @nycds/button
2
2
 
3
+ ## 0.5.0-prerelease.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6052344: Add export maps to all packages
8
+ - ddd68c2: Feat: Add TS types export
9
+
10
+ ### Patch Changes
11
+
12
+ - aa61601: Limit published files to dist, src and CHANGELOG.md
13
+ - Updated dependencies [aa61601]
14
+ - @nycds/config@0.2.1-prerelease.0
15
+
3
16
  ## 0.4.0
4
17
 
5
18
  ### Minor Changes
package/README.org CHANGED
@@ -6,7 +6,7 @@ Buttons encourage users to take an action. They use text or icons to communicate
6
6
 
7
7
  The primary button can be utilized with a ~button~ or ~a~ element, with the following:
8
8
  - *Class*: ~nyc-button~
9
- - *Attribute*: ~data-variant="primary"~
9
+ - *Attribute* (optional): ~data-variant="primary"~. Primary is the default style, so ~nyc-button~ on its own is a primary button.
10
10
 
11
11
  #+results: primary-button-example
12
12
 
@@ -41,7 +41,7 @@ The secondary button can be utilized with a ~button~ or ~a~ element, with the fo
41
41
  The icon button can be utilized with a ~button~ or ~a~ element, with the following attributes:
42
42
  - *Class*: ~nyc-button~
43
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]]).
44
+ - *Icon element*: An icon element should be placed inside the button or link, using an icon class from the icons package (The package draws from the [[https://icon-sets.iconify.design/ph/][Iconify: Phosphor Iconset]]). Give the button an ~aria-label~, since it has no visible text.
45
45
 
46
46
  #+results: icon-button-example
47
47
 
@@ -0,0 +1,15 @@
1
+ declare class NYCBackToTop extends HTMLElement {
2
+ static define(name?: string): void;
3
+ isLongPage: boolean;
4
+ isScrolledEnough: boolean;
5
+ isScrollTick: boolean;
6
+ button: Element;
7
+ dynamicContainer: Element;
8
+ resizeObserver: ResizeObserver;
9
+ queuedHeightCheck: number;
10
+ connectedCallback(): void;
11
+ disconnectedCallback(): void;
12
+ #private;
13
+ }
14
+
15
+ export { NYCBackToTop };
package/package.json CHANGED
@@ -1,16 +1,37 @@
1
1
  {
2
2
  "name": "@nycds/button",
3
- "version": "0.4.0",
3
+ "version": "0.5.0-prerelease.0",
4
4
  "type": "module",
5
5
  "main": "src/js/index.js",
6
+ "types": "dist/button.d.ts",
6
7
  "style": "dist/button.css",
7
8
  "dependencies": {
8
- "@nycds/config": "^0.2.0"
9
+ "@nycds/config": "^0.2.1-prerelease.0"
9
10
  },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/button.d.ts",
14
+ "style": "./dist/button.css",
15
+ "import": "./src/js/index.js",
16
+ "default": "./src/js/index.js"
17
+ },
18
+ "./style": "./dist/button.css",
19
+ "./style.min": "./dist/button.min.css",
20
+ "./style/aem": "./dist/button-aem.css",
21
+ "./style/aem.min": "./dist/button-aem.min.css",
22
+ "./source/css": "./src/css/index.css",
23
+ "./*": "./*"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "src",
28
+ "CHANGELOG.md"
29
+ ],
10
30
  "scripts": {
11
31
  "clean": "rimraf ./dist",
12
32
  "build:css:default": "postcss src/css/index.css -o dist/button.css",
13
33
  "build:css:aem": "postcss src/css/aem/index.css -o dist/button-aem.css",
14
- "minify:css": "postcss dist/*.css --use cssnano --ext .min.css --dir dist --no-map"
34
+ "minify:css": "postcss dist/*.css --use cssnano --ext .min.css --dir dist --no-map",
35
+ "build:types": "node ../../../scripts/build-types.js"
15
36
  }
16
37
  }
package/css.org DELETED
@@ -1,344 +0,0 @@
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
package/postcss.config.js DELETED
@@ -1 +0,0 @@
1
- export { default } from '@nycds/config'
@@ -1,16 +0,0 @@
1
- import { test, expect } from '@playwright/test';
2
-
3
- test.describe('Back To Top', () => {
4
- test.describe('NYCBackToTop component', () => {
5
- let component;
6
- test.beforeEach(async ({ page }) => {
7
- await page.goto('/packages/components/button/tests/index.html')
8
- component = page.locator('nyc-back-to-top')
9
- })
10
-
11
- test('Back to top enabled at scroll point', async ({page, browserName }) => {
12
- await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight / 2))
13
- await expect(component).toContainClass('enabled')
14
- })
15
- })
16
- })
package/tests/index.html DELETED
@@ -1,20 +0,0 @@
1
- <html>
2
- <head>
3
- <link href="../../../core/dist/nycds-core.css" rel="stylesheet" />
4
- </head>
5
- <body>
6
-
7
- <div style="height: 500vh" class="backtotop-observe">
8
- </div>
9
- <nyc-back-to-top>
10
- <button id="back-to-top" class="nyc-button" data-variant="back-to-top" aria-label="Back to top">
11
- <span>Back to top</span>
12
- </button>
13
- </nyc-back-to-top>
14
-
15
- <script type="module">
16
- import { NYCBackToTop } from '../src/js/index.js'
17
- NYCBackToTop.define()
18
- </script>
19
- </body>
20
- </html>