@primer/octicons 17.12.0 → 18.1.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 +163 -1
- package/build/build/data.json +1 -1
- package/build/build/svg/issue-tracked-by-16.svg +1 -1
- package/build/build/svg/issue-tracked-by-24.svg +1 -1
- package/build/build/svg/issue-tracks-16.svg +1 -0
- package/build/build/svg/issue-tracks-24.svg +1 -0
- package/build/build/svg/passkey-fill-16.svg +1 -0
- package/build/build/svg/passkey-fill-24.svg +1 -0
- package/build/build/svg/shield-slash-24.svg +1 -0
- package/build/data.json +1 -1
- package/build/svg/issue-tracked-by-16.svg +1 -1
- package/build/svg/issue-tracked-by-24.svg +1 -1
- package/build/svg/issue-tracks-16.svg +1 -0
- package/build/svg/issue-tracks-24.svg +1 -0
- package/build/svg/passkey-fill-16.svg +1 -0
- package/build/svg/passkey-fill-24.svg +1 -0
- package/build/svg/shield-slash-24.svg +1 -0
- package/package.json +1 -1
- package/build/build/svg/issue-tracked-in-16.svg +0 -1
- package/build/build/svg/issue-tracked-in-24.svg +0 -1
- package/build/svg/issue-tracked-in-16.svg +0 -1
- package/build/svg/issue-tracked-in-24.svg +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,167 @@
|
|
|
1
1
|
# @primer/octicons
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
[](https://www.npmjs.org/package/@primer/octicons)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
This package is distributed with [npm][npm]. After [installing npm][install-npm], you can install `@primer/octicons` with this command:
|
|
9
|
+
|
|
10
|
+
```shell
|
|
11
|
+
npm install @primer/octicons
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
For all the usages, we recommend using the CSS located in [`build/build.css`](https://unpkg.com/@primer/octicons/build/build.css). This is some simple CSS to normalize the icons and inherit colors.
|
|
17
|
+
|
|
18
|
+
After installing `@primer/octicons` you can access the icons like this:
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
var octicons = require("@primer/octicons")
|
|
22
|
+
octicons.alert
|
|
23
|
+
// {
|
|
24
|
+
// symbol: 'alert',
|
|
25
|
+
// keywords: ['warning', 'triangle', 'exclamation', 'point'],
|
|
26
|
+
// toSVG: [Function]
|
|
27
|
+
// heights: {
|
|
28
|
+
// 16: {
|
|
29
|
+
// width: 16,
|
|
30
|
+
// path: '<path d="M8.865 1.52c-.18-.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h13.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h-2V6h2v4z"/>',
|
|
31
|
+
// options: {
|
|
32
|
+
// version: '1.1',
|
|
33
|
+
// width: '16',
|
|
34
|
+
// height: '16',
|
|
35
|
+
// viewBox: '0 0 16 16',
|
|
36
|
+
// class: 'octicon octicon-alert',
|
|
37
|
+
// 'aria-hidden': 'true'
|
|
38
|
+
// },
|
|
39
|
+
// },
|
|
40
|
+
// 24: ...
|
|
41
|
+
// }
|
|
42
|
+
// }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
There will be a key for every icon, with [`toSVG`](#octiconsnametosvg) and other properties.
|
|
46
|
+
|
|
47
|
+
_Note: `alert` in the above example can be replaced with any valid icon name. Icons with multi-word names (e.g. `arrow-right`) **cannot** be accessed using dot notation (e.g. `octicons.alert`). Instead, use bracket notation (e.g. `octicons['arrow-right']`)._
|
|
48
|
+
|
|
49
|
+
### `octicons[name].symbol`
|
|
50
|
+
|
|
51
|
+
Returns the string of the symbol name, same as the key for that icon.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
octicons.x.symbol
|
|
55
|
+
// "x"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### `octicons[name].keywords`
|
|
59
|
+
|
|
60
|
+
Returns an array of keywords for the icon. The data comes from [keywords.json](https://github.com/primer/octicons/blob/main/keywords.json). Consider contributing more aliases for the icons.
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
octicons.x.keywords
|
|
64
|
+
// ["remove", "close", "delete"]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### `octicons[name].heights`
|
|
68
|
+
|
|
69
|
+
Each icon can have multiple SVGs that are designed for different sizes. The `heights` property allows you to access all the SVGs for an icon using the natural height of the SVG.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
octicons.x.heights
|
|
74
|
+
// {
|
|
75
|
+
// 16: {
|
|
76
|
+
// width: 16,
|
|
77
|
+
// path: '<path d="..."/>',
|
|
78
|
+
// options: {
|
|
79
|
+
// version: '1.1',
|
|
80
|
+
// width: '16',
|
|
81
|
+
// height: '16',
|
|
82
|
+
// viewBox: '0 0 16 16',
|
|
83
|
+
// class: 'octicon octicon-alert',
|
|
84
|
+
// 'aria-hidden': 'true'
|
|
85
|
+
// },
|
|
86
|
+
// },
|
|
87
|
+
// 24: {
|
|
88
|
+
// width: 24,
|
|
89
|
+
// path: '<path d="..."/>',
|
|
90
|
+
// options: {
|
|
91
|
+
// version: '1.1',
|
|
92
|
+
// width: '24',
|
|
93
|
+
// height: '24',
|
|
94
|
+
// viewBox: '0 0 24 24',
|
|
95
|
+
// class: 'octicon octicon-alert',
|
|
96
|
+
// 'aria-hidden': 'true'
|
|
97
|
+
// },
|
|
98
|
+
// },
|
|
99
|
+
// }
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
### `octicons[name].heights[height].width`
|
|
104
|
+
|
|
105
|
+
Returns the icon's true width, based on the SVG view box width. _Note, this doesn't change if you scale it up with size options, it only is the natural width of the icon._
|
|
106
|
+
|
|
107
|
+
### `octicons[name].heights[height].path`
|
|
108
|
+
|
|
109
|
+
Returns the string representation of the path of the icon.
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
octicons.x.heights[16].path
|
|
113
|
+
// <path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### `octicons[name].heights[height].options`
|
|
117
|
+
|
|
118
|
+
This is an object of all the attributes that will be added to the output tag.
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
octicons.x.heights[16].options
|
|
122
|
+
// { version: '1.1', width: '12', height: '16', viewBox: '0 0 12 16', class: 'octicon octicon-x', 'aria-hidden': 'true' }
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### `octicons[name].toSVG()`
|
|
126
|
+
|
|
127
|
+
Returns a string of the `<svg>` tag.
|
|
128
|
+
|
|
129
|
+
```js
|
|
130
|
+
octicons.x.toSVG()
|
|
131
|
+
// <svg version="1.1" width="12" height="16" viewBox="0 0 12 16" class="octicon octicon-x" aria-hidden="true"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"/></svg>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The `.toSVG()` method accepts an optional `options` object. This is used to add CSS class names, accessibility options, and sizes.
|
|
135
|
+
|
|
136
|
+
#### class
|
|
137
|
+
|
|
138
|
+
Add more CSS classes to the `<svg>` tag.
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
octicons.x.toSVG({ "class": "close" })
|
|
142
|
+
// <svg version="1.1" width="12" height="16" viewBox="0 0 12 16" class="octicon octicon-x close" aria-hidden="true"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"/></svg>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### aria-label
|
|
146
|
+
|
|
147
|
+
Add accessibility `aria-label` to the icon.
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
octicons.x.toSVG({ "aria-label": "Close the window" })
|
|
151
|
+
// <svg version="1.1" width="12" height="16" viewBox="0 0 12 16" class="octicon octicon-x" aria-label="Close the window" role="img"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"/></svg>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### width and height
|
|
155
|
+
|
|
156
|
+
Size the SVG icon larger using `width` and `height` independently or together. `.toSVG()` will automatically choose the best SVG to render based on the width or height passed in.
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
octicons.x.toSVG({ "width": 45 })
|
|
160
|
+
// <svg version="1.1" width="45" height="45" viewBox="0 0 24 24" class="octicon octicon-x" aria-hidden="true"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"/></svg>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
[primer]: https://github.com/primer/primer
|
|
164
|
+
[docs]: http://primercss.io/
|
|
165
|
+
[npm]: https://www.npmjs.com/
|
|
166
|
+
[install-npm]: https://docs.npmjs.com/getting-started/installing-node
|
|
167
|
+
[sass]: http://sass-lang.com/
|