You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://www.webcomponents.org/element/github-corner-element)
A web component for the corner banner of GitHub, inspired by [Tim Holman](https://github.com/tholman)'s [GitHub Corners](https://github.com/tholman/github-corners).
<p>A web component for the corner banner of GitHub, inspired by <ahref="https://github.com/tholman">Tim Holman</a>'s <ahref="https://github.com/tholman/github-corners">GitHub Corners</a>.</p>
<p>It's compatible with browsers which supports <ahref="https://developer.mozilla.org/en-US/docs/Web/Web_Components">Web Component</a>(including <code>Custom elements</code>, <code>Shadow DOM</code> and <code>HTML Template</code>). For modern browsers it should be fine, but old browser may not work. Checkout the compatibility <ahref="https://caniuse.com/?search=web%20component">here</a>.</p>
<p>After installation you can use it as well as a normal HTML element:</p>
259
+
<pre><codeclass="hljs html language-html"><spanclass="hljs-tag"><<spanclass="hljs-name">github-corner</span><spanclass="hljs-attr">href</span>=<spanclass="hljs-string">"https://github.com/YuskaWu/github-corner-element"</span>></span><spanclass="hljs-tag"></<spanclass="hljs-name">github-corner</span>></span></code></pre>
260
+
<h2id="attributes">Attributes</h2>
261
+
<p>In addition to the <ahref="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes">global attributes</a>, you can also use<br/>
262
+
the following additional attributes on <code>github-corner</code> element:</p>
263
+
<table>
264
+
<thead>
265
+
<tr>
266
+
<thid="attribute_name">Attribute Name</th>
267
+
<thid="type">Type</th>
268
+
<thid="default_value">Default Value</th>
269
+
<thid="description">Description</th>
270
+
</tr>
271
+
</thead>
272
+
<tbody>
273
+
<tr>
274
+
<td>href</td>
275
+
<td><ahref="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href">href attribute</a> of anchor element</td>
276
+
<td>none</td>
277
+
<td>The URL of github page.</td>
278
+
</tr>
279
+
<tr>
280
+
<td>size</td>
281
+
<td>value of <ahref="https://developer.mozilla.org/en-US/docs/Web/CSS/width">width CSS property</a></td>
282
+
<td>5rem</td>
283
+
<td>The width and height of github-corner element.</td>
<td>The placement of github-corner element, it can be one of the four corners.</td>
290
+
</tr>
291
+
<tr>
292
+
<td>octocat-color</td>
293
+
<td>value of <ahref="https://developer.mozilla.org/en-US/docs/Web/CSS/color">color CSS property</a></td>
294
+
<td>white</td>
295
+
<td>The color of the octocat.</td>
296
+
</tr>
297
+
<tr>
298
+
<td>banner-color</td>
299
+
<td>value of <ahref="https://developer.mozilla.org/en-US/docs/Web/CSS/color">color CSS property</a></td>
300
+
<td>black</td>
301
+
<td>The color of the banner.</td>
302
+
</tr>
303
+
<tr>
304
+
<td>wave-duration</td>
305
+
<td>value of <ahref="https://developer.mozilla.org/en-US/docs/Web/CSS/animation-duration">animation-duration CSS property</a></td>
306
+
<td>0.5s</td>
307
+
<td>The duration to wave octocat's hand.</td>
308
+
</tr>
309
+
</tbody>
310
+
</table>
311
+
<p>Checkout this <ahref="https://yuskawu.github.io/github-corner-element/example">page</a> for more examples.</p>
312
+
<h2id="styling">Styling</h2>
313
+
<p>As normal HTML element, you can style it with <code>class</code> and <code>style</code> attribute. But if you want to style elements which is inside the shadow DOM, then you have to use <ahref="https://developer.mozilla.org/en-US/docs/Web/CSS/::part">::part()</a> CSS pseudo-element.</p>
314
+
<p>There are five parts in shadow DOM that can be selected by <ahref="https://developer.mozilla.org/en-US/docs/Web/CSS/::part">::part()</a>:</p>
315
+
<ul>
316
+
<li>anchor</li>
317
+
<li>banner</li>
318
+
<li>octocat</li>
319
+
<li>octocat-arm</li>
320
+
<li>octocat-body</li>
321
+
</ul>
322
+
<p>You can use devtool to inspect shadow DOM and checkout the position of these parts.</p>
323
+
<p>Here is an example to style the parts inside shadow DOM(see live demo <ahref="https://yuskawu.github.io/github-corner-element/example#ex-styling">here</a>):</p>
324
+
<pre><codeclass="hljs html language-html"><spanclass="hljs-tag"><<spanclass="hljs-name">style</span>></span><spanclass="language-css">
<p>NOTE: Using this way will have more specificity, styling by the attributes listed above will be overwritten.</p>
352
+
</blockquote>
353
+
<h2id="svg-slot">svg slot</h2>
354
+
<p>There is a <ahref="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot">slot</a> named <code>"svg"</code>, SVG element on the slot will be cloned and append into the SVG container inside shadow DOM. If you want to add additional SVG to draw something special, or you want to define SVG gradients, you can use the slot to do so.</p>
355
+
<p>Here is an example to draw eyes on octocat(see live demo <ahref="https://yuskawu.github.io/github-corner-element/example#ex-slot-eyes">here</a>):</p>
356
+
<pre><codeclass="hljs html language-html"><spanclass="hljs-tag"><<spanclass="hljs-name">github-corner</span>></span>
0 commit comments