Skip to content

Commit b0e1687

Browse files
authored
Add more Octicon support (#1694)
* Add colored octicon support to .suggester * Add octicon support for .radio-group + disabled state * Add support for octicon in .btn in .flash * Create dry-tips-scream.md
1 parent 014e522 commit b0e1687

File tree

7 files changed

+100
-13
lines changed

7 files changed

+100
-13
lines changed

.changeset/dry-tips-scream.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/css": minor
3+
---
4+
5+
Add more Octicon icon support to components

docs/content/components/alerts.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,25 @@ Add an icon to the left of the flash message to give it some funky fresh attenti
6969
```html live
7070
<div class="flash">
7171
<!-- <%= octicon "info" %> -->
72-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm6.5-.25A.75.75 0 017.25 7h1a.75.75 0 01.75.75v2.75h.25a.75.75 0 010 1.5h-2a.75.75 0 010-1.5h.25v-2h-.25a.75.75 0 01-.75-.75zM8 6a1 1 0 100-2 1 1 0 000 2z"></path></svg>
72+
<svg class="octicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm6.5-.25A.75.75 0 017.25 7h1a.75.75 0 01.75.75v2.75h.25a.75.75 0 010 1.5h-2a.75.75 0 010-1.5h.25v-2h-.25a.75.75 0 01-.75-.75zM8 6a1 1 0 100-2 1 1 0 000 2z"></path></svg>
7373
Flash message with an icon
7474
</div>
7575

7676
<div class="flash mt-3 flash-warn">
7777
<!-- <%= octicon "alert" %> -->
78-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path></svg>
78+
<svg class="octicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path></svg>
7979
Flash message with an icon
8080
</div>
8181

8282
<div class="flash mt-3 flash-error">
8383
<!-- <%= octicon "stop" %> -->
84-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M4.47.22A.75.75 0 015 0h6a.75.75 0 01.53.22l4.25 4.25c.141.14.22.331.22.53v6a.75.75 0 01-.22.53l-4.25 4.25A.75.75 0 0111 16H5a.75.75 0 01-.53-.22L.22 11.53A.75.75 0 010 11V5a.75.75 0 01.22-.53L4.47.22zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5H5.31zM8 4a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 018 4zm0 8a1 1 0 100-2 1 1 0 000 2z"></path></svg>
84+
<svg class="octicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M4.47.22A.75.75 0 015 0h6a.75.75 0 01.53.22l4.25 4.25c.141.14.22.331.22.53v6a.75.75 0 01-.22.53l-4.25 4.25A.75.75 0 0111 16H5a.75.75 0 01-.53-.22L.22 11.53A.75.75 0 010 11V5a.75.75 0 01.22-.53L4.47.22zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5H5.31zM8 4a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 018 4zm0 8a1 1 0 100-2 1 1 0 000 2z"></path></svg>
8585
Flash message with an icon
8686
</div>
8787

8888
<div class="flash mt-3 flash-success">
8989
<!-- <%= octicon "check" %> -->
90-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg>
90+
<svg class="octicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg>
9191
Flash message with an icon
9292
</div>
9393
```
@@ -147,22 +147,29 @@ A flash message with an action button.
147147
```html live
148148
<div class="flash">
149149
Flash message with action here.
150-
<button type="submit" class="btn btn-sm primary flash-action">Complete action</button>
150+
<button type="submit" class="btn btn-sm flash-action">Complete action</button>
151151
</div>
152152

153153
<div class="flash mt-3 flash-warn">
154154
Flash message with action here.
155-
<button class="btn btn-sm primary flash-action" type="submit">Complete action</button>
155+
<button class="btn btn-sm flash-action" type="submit">Complete action</button>
156156
</div>
157157

158158
<div class="flash mt-3 flash-error">
159159
Flash message with action here.
160-
<button class="btn btn-sm primary flash-action" type="submit">Complete action</button>
160+
<button class="btn btn-sm flash-action" type="submit">
161+
<svg class="octicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M6.5 1.75a.25.25 0 01.25-.25h2.5a.25.25 0 01.25.25V3h-3V1.75zm4.5 0V3h2.25a.75.75 0 010 1.5H2.75a.75.75 0 010-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75zM4.496 6.675a.75.75 0 10-1.492.15l.66 6.6A1.75 1.75 0 005.405 15h5.19c.9 0 1.652-.681 1.741-1.576l.66-6.6a.75.75 0 00-1.492-.149l-.66 6.6a.25.25 0 01-.249.225h-5.19a.25.25 0 01-.249-.225l-.66-6.6z"></path></svg>
162+
Complete action
163+
</button>
161164
</div>
162165

163166
<div class="flash mt-3 flash-success">
167+
<svg class="octicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M5.75 7.5a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5a.75.75 0 01.75-.75zm5.25.75a.75.75 0 00-1.5 0v1.5a.75.75 0 001.5 0v-1.5z"></path><path fill-rule="evenodd" d="M6.25 0a.75.75 0 000 1.5H7.5v2H3.75A2.25 2.25 0 001.5 5.75V8H.75a.75.75 0 000 1.5h.75v2.75a2.25 2.25 0 002.25 2.25h8.5a2.25 2.25 0 002.25-2.25V9.5h.75a.75.75 0 000-1.5h-.75V5.75a2.25 2.25 0 00-2.25-2.25H9V.75A.75.75 0 008.25 0h-2zM3 5.75A.75.75 0 013.75 5h8.5a.75.75 0 01.75.75v6.5a.75.75 0 01-.75.75h-8.5a.75.75 0 01-.75-.75v-6.5z"></path></svg>
164168
Flash message with action here.
165-
<button class="btn btn-sm primary flash-action" type="submit">Complete action</button>
169+
<button class="btn btn-sm flash-action" type="submit">
170+
<svg class="octicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2 2.75C2 1.784 2.784 1 3.75 1h2.5a.75.75 0 010 1.5h-2.5a.25.25 0 00-.25.25v10.5c0 .138.112.25.25.25h2.5a.75.75 0 010 1.5h-2.5A1.75 1.75 0 012 13.25V2.75zm10.44 4.5H6.75a.75.75 0 000 1.5h5.69l-1.97 1.97a.75.75 0 101.06 1.06l3.25-3.25a.75.75 0 000-1.06l-3.25-3.25a.75.75 0 10-1.06 1.06l1.97 1.97z"></path></svg>
171+
Complete action
172+
</button>
166173
</div>
167174
```
168175

docs/content/components/autocomplete.md

+20-5
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,26 @@ The `.suggester` component is meant for showing suggestions while typing in a la
5858
<div class="form-group position-relative">
5959
<textarea class="form-control width-full" placeholder="Leave a comment" aria-label="Comment body">This is on top of #</textarea>
6060
<ul class="suggester suggester-container" role="listbox" style="top: 4px; left: 125px;">
61-
<li aria-selected="true"> <small>#924</small> <span>Markdown tables are inaccessible</span> </li>
62-
<li> <small>#980</small> <span>Use actual book emoji in Flexbox docs</span> </li>
63-
<li> <small>#979</small> <span>Add `.radio-group` component</span> </li>
64-
<li> <small>#925</small> <span>Release 14.0.0</span> </li>
65-
<li> <small>#978</small> <span>Add `.css-truncate-overflow`</span> </li>
61+
<li aria-selected="true">
62+
<svg class="octicon color-fg-subtle" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path><path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z"></path></svg>
63+
<small>#924</small> <span>Markdown tables are inaccessible</span>
64+
</li>
65+
<li>
66+
<svg class="octicon color-fg-success" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path><path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z"></path></svg>
67+
<small>#980</small> <span>Use actual book emoji in Flexbox docs</span>
68+
</li>
69+
<li>
70+
<svg class="octicon color-fg-attention" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path><path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z"></path></svg>
71+
<small>#979</small> <span>Add `.radio-group` component</span>
72+
</li>
73+
<li>
74+
<svg class="octicon color-fg-danger" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path><path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z"></path></svg>
75+
<small>#925</small> <span>Release 14.0.0</span>
76+
</li>
77+
<li>
78+
<svg class="octicon color-fg-done" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path><path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z"></path></svg>
79+
<small>#978</small> <span>Add `.css-truncate-overflow`</span>
80+
</li>
6681
</ul>
6782
</div>
6883

docs/content/components/forms.md

+24
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,27 @@ Radio groups are tab like controls. Their blue border gives extra emphasis to wh
392392
</div>
393393
</form>
394394
```
395+
396+
Adding `octicon` icons is also supported. To disable an option, use the `disabled` attribute.
397+
398+
```html live
399+
<form>
400+
<div class="radio-group">
401+
<input class="radio-input" id="option-a" type="radio" name="options">
402+
<label class="radio-label" for="option-a">
403+
<svg class="octicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z"></path></svg>
404+
Option A
405+
</label>
406+
<input class="radio-input" id="option-b" type="radio" name="options">
407+
<label class="radio-label" for="option-b">
408+
<svg class="octicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 000-.354l-1.086-1.086zM11.189 6.25L9.75 4.81l-6.286 6.287a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.249.249 0 00.108-.064l6.286-6.286z"></path></svg>
409+
Option B
410+
</label>
411+
<input class="radio-input" id="option-c" type="radio" name="options" disabled>
412+
<label class="radio-label" for="option-c">
413+
<svg class="octicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M6.5 1.75a.25.25 0 01.25-.25h2.5a.25.25 0 01.25.25V3h-3V1.75zm4.5 0V3h2.25a.75.75 0 010 1.5H2.75a.75.75 0 010-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75zM4.496 6.675a.75.75 0 10-1.492.15l.66 6.6A1.75 1.75 0 005.405 15h5.19c.9 0 1.652-.681 1.741-1.576l.66-6.6a.75.75 0 00-1.492-.149l-.66 6.6a.25.25 0 01-.249.225h-5.19a.25.25 0 01-.249-.225l-.66-6.6z"></path></svg>
414+
Option C
415+
</label>
416+
</div>
417+
</form>
418+
```

src/alerts/flash.scss

+9
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@
5757
margin-top: -3px;
5858
margin-left: $spacer-4;
5959
background-clip: padding-box;
60+
61+
&.btn .octicon {
62+
margin-right: $spacer-1;
63+
color: var(--color-fg-muted);
64+
}
65+
66+
&.btn-primary .octicon {
67+
color: inherit;
68+
}
6069
}
6170

6271
//

src/autocomplete/suggester.scss

+8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
small {
4747
color: var(--color-fg-on-emphasis);
4848
}
49+
50+
.octicon {
51+
color: inherit !important;
52+
}
4953
}
5054

5155
&[aria-selected="true"],
@@ -57,6 +61,10 @@
5761
small {
5862
color: var(--color-fg-on-emphasis);
5963
}
64+
65+
.octicon {
66+
color: inherit !important;
67+
}
6068
}
6169
}
6270
}

src/forms/radio-group.scss

+19
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,30 @@
3333
border-top-right-radius: $border-radius;
3434
border-bottom-right-radius: $border-radius;
3535
}
36+
37+
.octicon {
38+
margin-left: $spacer-1;
39+
color: var(--color-fg-subtle);
40+
}
3641
}
3742

3843
.radio-input {
3944
z-index: 3;
4045
float: left;
4146
// stylelint-disable-next-line primer/spacing
4247
margin: 10px (-$spacer-5) 0 $spacer-3;
48+
49+
&:disabled {
50+
position: relative; // enables z-index
51+
52+
+ .radio-label {
53+
color: var(--color-primer-fg-disabled);
54+
cursor: default;
55+
background-color: var(--color-neutral-subtle);
56+
57+
.octicon {
58+
color: inherit;
59+
}
60+
}
61+
}
4362
}

0 commit comments

Comments
 (0)