Skip to content

Commit 6b32227

Browse files
committed
Permalinks
Also delay making links clickable via `pointer-events` to avoid accidentals
1 parent 770d630 commit 6b32227

File tree

8 files changed

+67
-19
lines changed

8 files changed

+67
-19
lines changed

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ <h1>
3434
<wrap-if :is="feature.title ? 'span' : 'code'" class="title" v-else v-text="feature.title ?? feature.code ?? feature.id"></wrap-if>
3535
</wrap-if>
3636

37-
<div class="meta" v-if="feature.link || feature.mdnLink">
37+
<div class="meta" v-if="permalink || feature.link || feature.mdnLink">
38+
<a v-if="permalink" :href="permalink" class="icon-before permalink" title="Permalink"></a>
3839
<a v-if="feature.link && feature.spec" :href="feature.link" target="_blank" class="badge primary spec-link" :class="`${feature.spec.org.id}-link`">
3940
{{ feature.spec.org.title }}
4041
<span v-if="feature.link === feature.draftLink">Proposal</span>

src/vue/components/feature/feature.css

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
display: flex;
2828
gap: .2em;
2929
align-items: center;
30+
31+
:where(&) > a {
32+
/* Default icon */
33+
--icon: var(--icon-link);
34+
}
3035
}
3136
}
3237

@@ -84,12 +89,17 @@
8489
position: relative;
8590
--progress-color: oklch(from var(--color) calc(l + 0.4) 0 0);
8691

87-
.badge {
88-
transition: opacity 100ms 100ms;
92+
.badge, .permalink {
93+
transition: opacity 300ms 100ms, pointer-events 0ms 500ms;
94+
transition-behavior: allow-discrete;
8995
}
9096

91-
&:not(:hover, :focus-within, :target) .badge {
92-
opacity: 0;
97+
&:not(:hover, :focus-within, :target) {
98+
.badge, .permalink {
99+
pointer-events: none;
100+
transition-duration: 100ms;
101+
opacity: 0;
102+
}
93103
}
94104

95105
.progress {

src/vue/components/feature/feature.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,21 @@ export default {
8181

8282
showFeatureCount () {
8383
return this.feature.score.total > 1 && (!this.parent || this.parent.score.total !== this.feature.score.total);
84-
}
84+
},
85+
86+
permalink () {
87+
if (this.species === 'Spec') {
88+
let urlParams = new URLSearchParams(location.search);
89+
urlParams.set('spec', this.feature.id);
90+
return '?' + urlParams.toString();
91+
}
92+
93+
if (this.species === 'Feature') {
94+
return '#' + this.feature.htmlId;
95+
}
96+
97+
return '';
98+
},
8599
},
86100

87101
methods: {

ui/css/icons.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
--icon-caret: url('../icons/caret.svg');
44
--icon-x: url('../icons/x.svg');
55
--icon-warning: url('../icons/warning.svg');
6+
--icon-link: url('../icons/link.svg');
7+
--icon-link-external: url('../icons/link-external.svg');
68
--icon-w3c: url('../icons/w3c.svg');
79
--icon-mdn: url('../icons/mdn.svg');
810
--icon-whatwg: url('../icons/whatwg.svg');

ui/css/style.css

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,35 @@ h2 {
102102
mask: var(--icon) no-repeat center / contain;
103103
}
104104

105-
.icon-before::before,
106-
.spec-link::before {
107-
margin-inline-end: .2em;
105+
.icon-before,
106+
.spec-link {
107+
&:not(:empty)::before {
108+
margin-inline-end: .2em;
109+
}
108110
}
109111

110-
.spec-links {
111-
display: flex;
112-
align-items: center;
113-
gap: calc(0.15rem + 0.15em);
112+
a.icon-before,
113+
button.icon-before {
114+
display: inline-flex;
115+
cursor: pointer;
116+
padding: .3rem .4rem;
117+
border-radius: var(--radius-s);
118+
line-height: 1;
119+
120+
&:hover {
121+
background-color: oklab(from currentColor l a b / 20%)
122+
}
114123
}
115124

125+
.permalink {
126+
transition: opacity 100ms 100ms;
127+
128+
&:not(:hover, :focus-within) {
129+
opacity: .7;
130+
}
131+
}
132+
133+
116134
.badge {
117135
--icon-color: light-dark(var(--accent-color), color-mix(in oklab, var(--accent-color), currentColor 50%));
118136
--accent-color-h: hsl(from var(--accent-color) h none none);
@@ -129,19 +147,17 @@ h2 {
129147
var(--accent-color-l) 0%, var(--badge-foreground-color))));
130148

131149
display: inline-flex;
150+
vertical-align: middle;
132151
align-items: center;
133152
gap: .1em;
134153
padding: .3em .4em;
154+
border-radius: var(--radius-s);
155+
background-color: var(--tinted-background-color, var(--badge-background-color));
156+
color: var(--tinted-foreground-color, var(--badge-foreground-color));
135157
font-family: var(--font-sans);
136158
font-size: var(--font-size-s);
137159
line-height: 1;
138160

139-
background-color: var(--tinted-background-color, var(--badge-background-color));
140-
color: var(--tinted-foreground-color, var(--badge-foreground-color));
141-
142-
border-radius: .25em;
143-
vertical-align: middle;
144-
145161
@container not style(--icon) {
146162
&::before {
147163
content: none;

ui/css/tokens.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,7 @@
9898

9999
--shadow-l: 0 .4em .7em -.3em var(--color-shade);
100100
--shadow-l-90deg: -.4em 0 .7em -.3em var(--color-shade);
101+
102+
--radius-s: .2rem;
103+
--radius-m: .3rem;
101104
}

ui/icons/external-link.svg

Lines changed: 1 addition & 0 deletions
Loading

ui/icons/link.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)