@nice-digital/nds-alphabet 0.2.0-alpha.0 → 0.3.0-alpha.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/README.md +149 -0
- package/lib/Alphabet.js +1 -1
- package/lib/__tests__/nds-alphabet.test.js +1 -1
- package/nds-alphabet.d.ts +3 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# `@nice-digital/nds-alphabet`
|
|
2
|
+
|
|
3
|
+
> Alphabet component for the NICE Design System
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install Node, and then:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i @nice-digital/nds-alphabet --save
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### React
|
|
16
|
+
|
|
17
|
+
Import the `Alphabet` and `Letter` components from the package and use within JSX:
|
|
18
|
+
|
|
19
|
+
```jsx
|
|
20
|
+
import React from "react";
|
|
21
|
+
import { Alphabet, Letter } from "@nice-digital/nds-alphabet";
|
|
22
|
+
|
|
23
|
+
const allLetters = "abcdefghijklmnopqrstuvwxyz".split("");
|
|
24
|
+
|
|
25
|
+
<Alphabet>
|
|
26
|
+
{allLetters.map(letter => (
|
|
27
|
+
<Letter key={letter} to={`#${letter}`} label={`Letter ${letter}`}>
|
|
28
|
+
{letter.toUpperCase()}
|
|
29
|
+
</Letter>
|
|
30
|
+
))}
|
|
31
|
+
</Alphabet>
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> Note: The React component automatically imports the SCSS, so there's no need to import the SCSS directly yourself.
|
|
36
|
+
|
|
37
|
+
#### Props (Alphabet)
|
|
38
|
+
|
|
39
|
+
##### chunky
|
|
40
|
+
|
|
41
|
+
- Type `boolean` (default: false)
|
|
42
|
+
|
|
43
|
+
Whether to render the alphabet in its chunky (i.e. large) variant. This will
|
|
44
|
+
get passed to its children as a modifier.
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
<Alphabet chunky>
|
|
48
|
+
{children}
|
|
49
|
+
</Alphabet>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
##### id
|
|
53
|
+
|
|
54
|
+
- Type `string` (default: "a-to-z")
|
|
55
|
+
|
|
56
|
+
The id to give the generated `<ol>` element. Defaults to "a-to-z" if not specified
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
<Alphabet id="test-id">
|
|
60
|
+
{children}
|
|
61
|
+
</Alphabet>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
##### children
|
|
65
|
+
|
|
66
|
+
- Type: `React.ReactNode`
|
|
67
|
+
|
|
68
|
+
As the Alphabet component renders an `ol` element, it must have at least one `<li>`
|
|
69
|
+
child.
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
<Alphabet>
|
|
73
|
+
<li>Item one</li>
|
|
74
|
+
<li>Item two</li>
|
|
75
|
+
<li>Item three</li>
|
|
76
|
+
</Alphabet>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Props (Letter)
|
|
80
|
+
|
|
81
|
+
##### to
|
|
82
|
+
|
|
83
|
+
- Type: `string`
|
|
84
|
+
|
|
85
|
+
If specified, the link destination. If not specified, a span is rendered instead.
|
|
86
|
+
|
|
87
|
+
##### label
|
|
88
|
+
|
|
89
|
+
- Type: `string`
|
|
90
|
+
|
|
91
|
+
Creates an `aria-label` attribute on the generated element.
|
|
92
|
+
|
|
93
|
+
##### elementType
|
|
94
|
+
|
|
95
|
+
- Type: `Element` (default: `a`)
|
|
96
|
+
|
|
97
|
+
The element type used to render the component; can be a React component.
|
|
98
|
+
|
|
99
|
+
### SCSS
|
|
100
|
+
|
|
101
|
+
If you're not using [React](#react), then import the SCSS directly into your application by:
|
|
102
|
+
|
|
103
|
+
```scss
|
|
104
|
+
@import "~@nice-digital/nds-alphabet/scss/alphabet";
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### HTML
|
|
108
|
+
|
|
109
|
+
If you're not using [React](#react), then include the [SCSS as above](#scss) and use the HTML:
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
#### Standard variant
|
|
113
|
+
```html
|
|
114
|
+
<ol class="alphabet" id="a-to-z">
|
|
115
|
+
<li class="alphabet__letter"><a href="#a" aria-label="Letter a">A</a></li>
|
|
116
|
+
<li class="alphabet__letter"><a href="#b" aria-label="Letter b">B</a></li>
|
|
117
|
+
<li class="alphabet__letter"><a href="#c" aria-label="Letter c">C</a></li>
|
|
118
|
+
...
|
|
119
|
+
<li class="alphabet__letter"><a href="#x" aria-label="Letter x">X</a></li>
|
|
120
|
+
<li class="alphabet__letter"><a href="#y" aria-label="Letter y">Y</a></li>
|
|
121
|
+
<li class="alphabet__letter"><a href="#z" aria-label="Letter z">Z</a></li>
|
|
122
|
+
</ol>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### Chunky variant
|
|
126
|
+
```html
|
|
127
|
+
<ol class="alphabet alphabet--chunky" id="a-to-z">
|
|
128
|
+
<li class="alphabet__letter alphabet__letter--chunky"><a href="#a" aria-label="Letter a">A</a></li>
|
|
129
|
+
<li class="alphabet__letter alphabet__letter--chunky"><a href="#b" aria-label="Letter b">B</a></li>
|
|
130
|
+
<li class="alphabet__letter alphabet__letter--chunky"><a href="#c" aria-label="Letter c">C</a></li>
|
|
131
|
+
...
|
|
132
|
+
<li class="alphabet__letter alphabet__letter--chunky"><a href="#x" aria-label="Letter x">X</a></li>
|
|
133
|
+
<li class="alphabet__letter alphabet__letter--chunky"><a href="#y" aria-label="Letter y">Y</a></li>
|
|
134
|
+
<li class="alphabet__letter alphabet__letter--chunky"><a href="#z" aria-label="Letter z">Z</a></li>
|
|
135
|
+
</ol>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### No links
|
|
139
|
+
```html
|
|
140
|
+
<ol class="alphabet" id="a-to-z">
|
|
141
|
+
<li class="alphabet__letter"><span aria-label="Letter a">A</span></li>
|
|
142
|
+
<li class="alphabet__letter"><span aria-label="Letter b">B</span></li>
|
|
143
|
+
<li class="alphabet__letter"><span aria-label="Letter c">C</span></li>
|
|
144
|
+
...
|
|
145
|
+
<li class="alphabet__letter"><span aria-label="Letter x">X</span></li>
|
|
146
|
+
<li class="alphabet__letter"><span aria-label="Letter y">Y</span></li>
|
|
147
|
+
<li class="alphabet__letter"><span aria-label="Letter z">Z</span></li>
|
|
148
|
+
</ol>
|
|
149
|
+
```
|
package/lib/Alphabet.js
CHANGED
|
@@ -18,7 +18,7 @@ require("../scss/alphabet.scss");
|
|
|
18
18
|
var _excluded = ["children", "id", "chunky"],
|
|
19
19
|
_excluded2 = ["children", "label", "to", "chunky", "elementType"];
|
|
20
20
|
|
|
21
|
-
var _jsxFileName = "C:\\
|
|
21
|
+
var _jsxFileName = "C:\\dev\\nice-design-system\\components\\nds-alphabet\\src\\Alphabet.js",
|
|
22
22
|
_this = void 0;
|
|
23
23
|
|
|
24
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -8,7 +8,7 @@ var _enzyme = require("enzyme");
|
|
|
8
8
|
|
|
9
9
|
var _Alphabet = require("../Alphabet");
|
|
10
10
|
|
|
11
|
-
var _jsxFileName = "C:\\
|
|
11
|
+
var _jsxFileName = "C:\\dev\\nice-design-system\\components\\nds-alphabet\\src\\__tests__\\nds-alphabet.test.js",
|
|
12
12
|
_this = void 0;
|
|
13
13
|
|
|
14
14
|
describe("Alphabet", function () {
|
package/nds-alphabet.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice-digital/nds-alphabet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha.0",
|
|
4
4
|
"description": "Alphabet component for the NICE Design System",
|
|
5
5
|
"main": "lib/Alphabet.js",
|
|
6
6
|
"module": "es/Alphabet.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"url": "https://github.com/nice-digital/nice-design-system/issues"
|
|
28
28
|
},
|
|
29
29
|
"keywords": [
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"alphabet",
|
|
31
|
+
"a to z"
|
|
32
32
|
],
|
|
33
33
|
"author": "Chris Barker <chris.barker@nice.org.uk>",
|
|
34
34
|
"homepage": "https://design-system.nice.org.uk/",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"prop-types": "^15.8.1"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "281c966b380ead58f34ec045c8f296ff11303e0f"
|
|
40
40
|
}
|