Skip to content

Commit c0583ec

Browse files
committed
fix(web-component): fix style issue.
1 parent 09830f4 commit c0583ec

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

web-component/demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<script type="module" src="./lib/index.js"></script>
99
</head>
1010
<body>
11-
<github-corners style="z-index: 9999;" top="0" position="fixed" aria-label="View source on GitHub" fill="red" color="blue" target="__blank" href="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/uiwjs/react-github-corners"></github-corners>
11+
<github-corners style="z-index: 9999;" top="0" right="0" position="fixed" aria-label="View source on GitHub" fill="red" color="blue" target="__blank" href="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/uiwjs/react-github-corners"></github-corners>
1212
<label>
1313
<input type="range" value="160" min="50" max="220" onChange="handleChange(this)" />
1414
</label>

web-component/src/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ GITHUB_CORNERS_TEMPLATE.innerHTML = `
2424
:host a:hover .octo-arm { animation: none; }
2525
:host .octo-arm { animation: octocat-wave 560ms ease-in-out; }
2626
}
27+
:host svg {
28+
position: fixed;
29+
border: 0px;
30+
top: 0px;
31+
}
2732
</style>
28-
<svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true" style="position: absolute; border: 0px; top: 0px;">
33+
<svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true">
2934
<a xlink:href="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/uiwjs/react-github-corners" target="_blank" rel="nofollow sponsored" style="fill: rgb(21, 21, 19); color: rgb(255, 255, 255);">
3035
<g>
3136
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
@@ -39,8 +44,8 @@ GITHUB_CORNERS_TEMPLATE.innerHTML = `
3944
export class GithubCorners extends HTMLElement {
4045
/** Sets the z-order of a positioned element and its descendants or flex items. */
4146
'z-index'?: string;
42-
height?: string;
43-
width?: string;
47+
height?: string | number;
48+
width?: string | number;
4449
href?: string;
4550
color?: string;
4651
fill?: string;
@@ -53,7 +58,7 @@ export class GithubCorners extends HTMLElement {
5358
transform?: string;
5459
private shadow: ShadowRoot
5560
static get observedAttributes(): string[] {
56-
return ['z-index', 'target', 'height', 'width', 'href', 'color', 'fill', 'position', 'top', 'left', 'right', 'bottom', 'transform'];
61+
return ['style', 'z-index', 'target', 'height', 'width', 'href', 'color', 'fill', 'position', 'top', 'left', 'right', 'bottom', 'transform'];
5762
}
5863
constructor() {
5964
super();
@@ -67,7 +72,7 @@ export class GithubCorners extends HTMLElement {
6772
svg.lastElementChild.setAttribute('xlink:href', value);
6873
} else if (/(color|fill)/.test(name.toLocaleLowerCase())) {
6974
(svg.firstElementChild as HTMLAnchorElement).style[name as any] = value;
70-
} else if (/(z-index|height|width|position|top|left|right|bottom|transform)/.test(name.toLocaleLowerCase())) {
75+
} else if (/(z-index|position|top|left|right|bottom|transform)/.test(name.toLocaleLowerCase())) {
7176
svg.style[name as any] = value;
7277
} else {
7378
svg.setAttribute(name, value);

0 commit comments

Comments
 (0)