Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit067fa19

Browse files
committed
feat(sites/ui): allow focusing lines, inpsired by shiki focus transformer
1 parent044a3b8 commit067fa19

File tree

5 files changed

+52
-1
lines changed

5 files changed

+52
-1
lines changed

‎.changeset/olive-laws-refuse.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltevietnam/ui':minor
3+
---
4+
5+
`:::focus` metaline for codeblock

‎libs/ui/src/css/typography/base/prose.css‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,19 @@
212212
}
213213
}
214214
}
215+
216+
&:has([data-focus]) {
217+
& .line:not([data-focus]) {
218+
opacity:0.5;
219+
filter:blur(0.095rem);
220+
transition: filter200ms ease-out;
221+
}
222+
223+
&:is(:focus,:hover) .line:not([data-focus]) {
224+
opacity:1;
225+
filter:blur(0);
226+
}
227+
}
215228
}
216229
}
217230

‎libs/ui/src/lib/preprocessors/mdsvex/shiki.js‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ function transformer() {
116116

117117
/**@typedef {{ type: 'diff'; variant: '-' | '+' }} BlockDiff */
118118
/**@typedef {{ type: 'highlight'; variant: typeof STATUSES[number]}} BlockHighlight */
119-
/**@typedef {BlockDiff | BlockHighlight} Block */
119+
/**@typedef {{ type: 'focus' }} BlockFocus */
120+
/**@typedef {BlockDiff | BlockHighlight | BlockFocus} Block */
120121

121122
/**@type {Block[]} */
122123
constblocks=[];
@@ -149,6 +150,14 @@ function transformer() {
149150
}
150151
}
151152

153+
// focus
154+
if(!match){
155+
match=str.match(/:::focus/);
156+
if(match){
157+
blocks.push({type:'focus'});
158+
}
159+
}
160+
152161
if(!match){
153162
blocks.pop();
154163
}
@@ -182,6 +191,9 @@ function transformer() {
182191
case'highlight':
183192
line.properties['data-line-highlighted']=block.variant;
184193
break;
194+
case'focus':
195+
line.properties['data-focus']='';
196+
break;
185197
}
186198
}
187199
}

‎sites/www/src/routes/(localized)/design/blog/code/_page/content.md.svelte‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
importFromFilefrom'./examples/from-file.md.svelte';
66
importMetaBlockDifffrom'./examples/meta-block-diff.md.svelte';
77
importMetaBlockHighlightfrom'./examples/meta-block-highlight.md.svelte';
8+
importMetaBlockFocusfrom'./examples/meta-block-focus.md.svelte';
89
importGroupFilesfrom'./examples/group-files.md.svelte';
910
importGroupTabsfrom'./examples/group-tabs.md.svelte';
1011
</script>
@@ -73,6 +74,17 @@
7374

7475
<MetaBlockHighlight />
7576

77+
### Focus
78+
79+
```markdown
80+
/// src=./examples/meta-block-focus.md.svelte
81+
/// skipMetaBlock=true
82+
```
83+
84+
...renders
85+
86+
<MetaBlockFocus />
87+
7688
## Group of Code Blocks
7789

7890
### "Files" Display Mode
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
```svelte
2+
<script>
3+
import {clickoutside }from'@svelte-put/clickoutside';
4+
</script>
5+
6+
<!-- :::focus -->
7+
<elementuse:clickoutsideon:clickoutside></element>
8+
<!-- ::: -->
9+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp