@primer/css 0.0.0-20220113180546 → 0.0.0-20220114013357
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 +1 -1
- package/button-refactor/ButtonsLinksAPI.md +68 -0
- package/button-refactor/button.scss +181 -0
- package/button-refactor/link.scss +0 -0
- package/core/index.scss +1 -1
- package/dist/core.css +1 -1
- package/dist/core.css.map +1 -1
- package/dist/meta.json +55 -55
- package/dist/primer.css +1 -1
- package/dist/primer.css.map +1 -1
- package/dist/stats/core.json +1 -1
- package/dist/stats/primer.json +1 -1
- package/package.json +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Button and Link component APIs
|
|
2
|
+
Button and Link has been discussed in a number of issues and discussions over past few years. I went through the list below, took note of their purpose and started compiling a new API spec. This doc is is meant to be collaborative and accompany Storybook docs while we work through a final API recommendation. Once we have a solid plan, this can move into an issue and be delegated across frameworks.
|
|
3
|
+
|
|
4
|
+
Existing issues
|
|
5
|
+
[x] https://github.com/github/primer/issues/141
|
|
6
|
+
- Accessory button component, should reconcile with reaction button (sister component to Button)
|
|
7
|
+
[x] https://github.com/github/primer/issues/220
|
|
8
|
+
- Tracking issue, mentions Button in the context of API consistency
|
|
9
|
+
[x] https://github.com/github/primer/issues/253
|
|
10
|
+
- Button audit, anatomy spec, design considerations, some button link discussion, icon buttons (this issue is very informative!)
|
|
11
|
+
[x] https://github.com/github/primer/issues/263
|
|
12
|
+
- More design discussion, particularly focused on outline button
|
|
13
|
+
[x] https://github.com/github/primer/issues/272
|
|
14
|
+
- Make icon only buttons square
|
|
15
|
+
[x] https://github.com/github/primer/issues/321
|
|
16
|
+
- Super specific button use case?
|
|
17
|
+
[x] https://github.com/github/primer/issues/350
|
|
18
|
+
- a11y audit with task list for PVC
|
|
19
|
+
[x] https://github.com/github/primer/issues/382
|
|
20
|
+
- React button refactor
|
|
21
|
+
[x] https://github.com/github/primer/issues/468
|
|
22
|
+
- Visual bugs (colors, state)
|
|
23
|
+
[x] https://github.com/github/primer/discussions/87
|
|
24
|
+
- Discussion about accessory buttons
|
|
25
|
+
[x] https://github.com/github/primer/discussions/211
|
|
26
|
+
- Open ended discussion about primary button as dropdown
|
|
27
|
+
[x] https://github.com/github/primer/discussions/459
|
|
28
|
+
- Allie's thoughts on limiting icon only buttons and working towards encouraging visual labels
|
|
29
|
+
[x] https://github.com/github/primer/discussions/477
|
|
30
|
+
- Buttons styled as links, links styled as buttons
|
|
31
|
+
|
|
32
|
+
## Specific notes from previous bugs to keep in mind
|
|
33
|
+
[] Check all button variants have shadow present
|
|
34
|
+
[] Ensure icon colors are consistent in hover states
|
|
35
|
+
[] Ensure icon colors are consistent with variants in all states
|
|
36
|
+
[] Ensure disabled colors are consistent across frameworks
|
|
37
|
+
|
|
38
|
+
## Component list
|
|
39
|
+
A few discussions were about naming and prop drilling (source here). We found that for Button to handle all of its use cases, we would need a large number of props– some conditional and dependent on one another. When that happens, it's typically a sign that the logic should be separated into another component.
|
|
40
|
+
|
|
41
|
+
| Component | Description |
|
|
42
|
+
| -- | -- |
|
|
43
|
+
| Button | standard `button` with variants, size, visual slots |
|
|
44
|
+
| IconButton | `button` with icon only (square) and required `aria-label` |
|
|
45
|
+
| ButtonStyledAsLink | `button` that visually looks like a link |
|
|
46
|
+
| ReactionButton | `button` snowflake with specific styles/interaction design |
|
|
47
|
+
| ButtonGroup | wrapper to handle grouping buttons |
|
|
48
|
+
| Link | `a` with variants, optional trailing visuals |
|
|
49
|
+
| LinkStyledAsButton | `a` with button variants, required trailing visuals |
|
|
50
|
+
|
|
51
|
+
## Component API breakdown
|
|
52
|
+
|
|
53
|
+
### Button
|
|
54
|
+
|
|
55
|
+
| prop | type | options | default | notes |
|
|
56
|
+
| -- | -- | -- | -- | -- |
|
|
57
|
+
| `variant` | one-of string | `primary` `secondary` `danger` `outline`? | `secondary` | |
|
|
58
|
+
| `size` | one-of string | `small` `default` `large` | `default | |
|
|
59
|
+
| `label` | string | button description | null | |
|
|
60
|
+
| `aria-label` | string | button description for screen readers | null | |
|
|
61
|
+
| `aria-pressed` | boolean | `true/false` | `false` | |
|
|
62
|
+
| `leadingVisual` | children (slot) | octicon | null | |
|
|
63
|
+
| `trailingVisual` | children (slot) | octicon | null | |
|
|
64
|
+
| `trailingAction` | children (slot) | octicon | null | slot for caret to maintain leading/trailing visuals if they exist |
|
|
65
|
+
| `fullWidth` | boolean | `true/false` | `false` | |
|
|
66
|
+
| `visualPosition` | one-of string | `fixed` `some-other-word` | `fixed` | lock icon to the text label or to the button container |
|
|
67
|
+
|
|
68
|
+
## Component design specs
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
.Button {
|
|
2
|
+
position: relative;
|
|
3
|
+
font-size: $body-font-size;
|
|
4
|
+
font-weight: $font-weight-semibold;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
user-select: none;
|
|
7
|
+
border: $border-width $border-style;
|
|
8
|
+
border-radius: $border-radius;
|
|
9
|
+
color: var(--color-btn-text);
|
|
10
|
+
background-color: var(--color-btn-bg);
|
|
11
|
+
border-color: var(--color-btn-border);
|
|
12
|
+
box-shadow: var(--color-btn-shadow), var(--color-btn-inset-shadow);
|
|
13
|
+
transition: 0.2s cubic-bezier(0.3, 0, 0.5, 1);
|
|
14
|
+
transition-property: color, background-color, border-color;
|
|
15
|
+
height: 32px;
|
|
16
|
+
padding: 0 16px;
|
|
17
|
+
display: grid;
|
|
18
|
+
grid-template-areas: 'leadingIcon text trailingIcon trailingAction';
|
|
19
|
+
grid-template-columns: min-content minmax(0, auto) min-content min-content;
|
|
20
|
+
align-items: center;
|
|
21
|
+
|
|
22
|
+
// column-gap persists with empty grid-areas, margin applies only when children exist
|
|
23
|
+
> :not(:last-child) {
|
|
24
|
+
margin-right: $spacer-2;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:hover,
|
|
28
|
+
&.hover,
|
|
29
|
+
[open] > & {
|
|
30
|
+
background-color: var(--color-btn-hover-bg);
|
|
31
|
+
border-color: var(--color-btn-hover-border);
|
|
32
|
+
transition-duration: 0.1s;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:active {
|
|
36
|
+
background-color: var(--color-btn-active-bg);
|
|
37
|
+
border-color: var(--color-btn-active-border);
|
|
38
|
+
transition: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.Button--pressed,
|
|
42
|
+
&[aria-pressed='true'] {
|
|
43
|
+
background-color: var(--color-btn-selected-bg);
|
|
44
|
+
box-shadow: var(--color-primer-shadow-inset);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&:disabled,
|
|
48
|
+
&.disabled,
|
|
49
|
+
&[aria-disabled='true'] {
|
|
50
|
+
color: var(--color-primer-fg-disabled);
|
|
51
|
+
background-color: var(--color-btn-bg);
|
|
52
|
+
border-color: var(--color-btn-border);
|
|
53
|
+
fill: var(--color-primer-fg-disabled);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&.Button-small {
|
|
57
|
+
height: 28px;
|
|
58
|
+
font-size: $font-size-small;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&.Button-large {
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&.Button-primary {
|
|
65
|
+
color: var(--color-btn-primary-text);
|
|
66
|
+
background-color: var(--color-btn-primary-bg);
|
|
67
|
+
border-color: var(--color-btn-primary-border);
|
|
68
|
+
box-shadow: var(--color-btn-primary-shadow), var(--color-btn-primary-inset-shadow);
|
|
69
|
+
|
|
70
|
+
&:hover,
|
|
71
|
+
&.hover,
|
|
72
|
+
[open] > & {
|
|
73
|
+
background-color: var(--color-btn-primary-hover-bg);
|
|
74
|
+
border-color: var(--color-btn-primary-hover-border);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&:active,
|
|
78
|
+
&.Button--pressed,
|
|
79
|
+
&[aria-pressed='true'] {
|
|
80
|
+
background-color: var(--color-btn-primary-selected-bg);
|
|
81
|
+
box-shadow: var(--color-btn-primary-selected-shadow);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:disabled,
|
|
85
|
+
&.disabled,
|
|
86
|
+
&[aria-disabled='true'] {
|
|
87
|
+
color: var(--color-btn-primary-disabled-text);
|
|
88
|
+
background-color: var(--color-btn-primary-disabled-bg);
|
|
89
|
+
border-color: var(--color-btn-primary-disabled-border);
|
|
90
|
+
fill: var(--color-btn-primary-disabled-text);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&.Button-secondary {
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&.Button-outline {
|
|
98
|
+
color: var(--color-btn-outline-text);
|
|
99
|
+
|
|
100
|
+
&:hover,
|
|
101
|
+
[open] > & {
|
|
102
|
+
color: var(--color-btn-outline-hover-text);
|
|
103
|
+
background-color: var(--color-btn-outline-hover-bg);
|
|
104
|
+
border-color: var(--color-btn-outline-hover-border);
|
|
105
|
+
box-shadow: var(--color-btn-outline-hover-shadow), var(--color-btn-outline-hover-inset-shadow);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&:active,
|
|
109
|
+
&.Button--pressed,
|
|
110
|
+
&[aria-pressed='true'] {
|
|
111
|
+
color: var(--color-btn-outline-selected-text);
|
|
112
|
+
background-color: var(--color-btn-outline-selected-bg);
|
|
113
|
+
border-color: var(--color-btn-outline-selected-border);
|
|
114
|
+
box-shadow: var(--color-btn-outline-selected-shadow);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&:disabled,
|
|
118
|
+
&.disabled,
|
|
119
|
+
&[aria-disabled='true'] {
|
|
120
|
+
color: var(--color-btn-outline-disabled-text);
|
|
121
|
+
background-color: var(--color-btn-outline-disabled-bg);
|
|
122
|
+
border-color: var(--color-btn-border);
|
|
123
|
+
box-shadow: none;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&.Button-danger {
|
|
128
|
+
color: var(--color-btn-danger-text);
|
|
129
|
+
|
|
130
|
+
.octicon {
|
|
131
|
+
color: var(--color-btn-danger-icon);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&:hover,
|
|
135
|
+
[open] > & {
|
|
136
|
+
color: var(--color-btn-danger-hover-text);
|
|
137
|
+
background-color: var(--color-btn-danger-hover-bg);
|
|
138
|
+
border-color: var(--color-btn-danger-hover-border);
|
|
139
|
+
box-shadow: var(--color-btn-danger-hover-shadow), var(--color-btn-danger-hover-inset-shadow);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&:active,
|
|
143
|
+
&.Button--pressed,
|
|
144
|
+
&[aria-pressed='true'] {
|
|
145
|
+
color: var(--color-btn-danger-selected-text);
|
|
146
|
+
background-color: var(--color-btn-danger-selected-bg);
|
|
147
|
+
border-color: var(--color-btn-danger-selected-border);
|
|
148
|
+
box-shadow: var(--color-btn-danger-selected-shadow);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&:disabled,
|
|
152
|
+
&.disabled,
|
|
153
|
+
&[aria-disabled='true'] {
|
|
154
|
+
color: var(--color-btn-danger-disabled-text);
|
|
155
|
+
background-color: var(--color-btn-danger-disabled-bg);
|
|
156
|
+
border-color: var(--color-btn-border);
|
|
157
|
+
box-shadow: none;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.Button--label {
|
|
163
|
+
grid-area: 'text';
|
|
164
|
+
white-space: nowrap;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.Button--visual {
|
|
168
|
+
display: flex;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.Button--leadingVisual {
|
|
172
|
+
grid-area: 'leadingVisual';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.Button--trailingVisual {
|
|
176
|
+
grid-area: 'trailingVisual';
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.Button--trailingAction {
|
|
180
|
+
grid-area: 'leadingAction';
|
|
181
|
+
}
|
|
File without changes
|
package/core/index.scss
CHANGED
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
@import '../pagination/index.scss';
|
|
25
25
|
@import '../tooltips/index.scss';
|
|
26
26
|
@import '../truncate/index.scss';
|
|
27
|
-
|
|
27
|
+
@import '../button-refactor/button.scss';
|
|
28
28
|
// Utilities always go last so that they can override components
|
|
29
29
|
@import '../utilities/index.scss';
|