Skip to content

Commit 205d791

Browse files
authored
Replace JS/TS toggle (#195)
* add icons * WIP * some CSS stuff * more CSS stuff * more CSS stuff * more CSS * tidy * fix * toggle file extensions * grumble grumble * make it work for .svelte files * synchronise and persist * shrink icon * remove copy button from dts snippets * tweaks * nicer icons/styles * remove some unused code * fix * tweak * unused * fix position * revert
1 parent 1fc5055 commit 205d791

28 files changed

+451
-631
lines changed

apps/svelte.dev/content/docs/svelte/98-reference/20-svelte.md

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ In runes mode use `$effect` instead.
3636

3737
<div class="ts-block">
3838

39-
```ts
40-
// @noErrors
39+
```dts
4140
function afterUpdate(fn: () => void): void;
4241
```
4342

@@ -53,8 +52,7 @@ In runes mode use `$effect.pre` instead.
5352

5453
<div class="ts-block">
5554

56-
```ts
57-
// @noErrors
55+
```dts
5856
function beforeUpdate(fn: () => void): void;
5957
```
6058

@@ -82,8 +80,7 @@ const dispatch = createEventDispatcher<{
8280

8381
<div class="ts-block">
8482

85-
```ts
86-
// @noErrors
83+
```dts
8784
function createEventDispatcher<
8885
EventMap extends Record<string, any> = any
8986
>(): EventDispatcher<EventMap>;
@@ -97,8 +94,7 @@ Create a snippet programmatically
9794

9895
<div class="ts-block">
9996

100-
```ts
101-
// @noErrors
97+
```dts
10298
function createRawSnippet<Params extends unknown[]>(
10399
fn: (...params: Getters<Params>) => {
104100
render: () => string;
@@ -115,8 +111,7 @@ Synchronously flushes any pending state changes and those that result from it.
115111

116112
<div class="ts-block">
117113

118-
```ts
119-
// @noErrors
114+
```dts
120115
function flushSync(fn?: (() => void) | undefined): void;
121116
```
122117

@@ -130,8 +125,7 @@ programmatically create a component and want to pass the existing context to it.
130125

131126
<div class="ts-block">
132127

133-
```ts
134-
// @noErrors
128+
```dts
135129
function getAllContexts<
136130
T extends Map<any, any> = Map<any, any>
137131
>(): T;
@@ -146,8 +140,7 @@ Must be called during component initialisation.
146140

147141
<div class="ts-block">
148142

149-
```ts
150-
// @noErrors
143+
```dts
151144
function getContext<T>(key: any): T;
152145
```
153146

@@ -160,8 +153,7 @@ Must be called during component initialisation.
160153

161154
<div class="ts-block">
162155

163-
```ts
164-
// @noErrors
156+
```dts
165157
function hasContext(key: any): boolean;
166158
```
167159

@@ -173,8 +165,7 @@ Hydrates a component on the given target and returns the exports and potentially
173165

174166
<div class="ts-block">
175167

176-
```ts
177-
// @noErrors
168+
```dts
178169
function hydrate<
179170
Props extends Record<string, any>,
180171
Exports extends Record<string, any>
@@ -211,8 +202,7 @@ Transitions will play during the initial render unless the `intro` option is set
211202

212203
<div class="ts-block">
213204

214-
```ts
215-
// @noErrors
205+
```dts
216206
function mount<
217207
Props extends Record<string, any>,
218208
Exports extends Record<string, any>
@@ -251,8 +241,7 @@ only one that runs inside a server-side component.
251241

252242
<div class="ts-block">
253243

254-
```ts
255-
// @noErrors
244+
```dts
256245
function onDestroy(fn: () => any): void;
257246
```
258247

@@ -270,8 +259,7 @@ If a function is returned _synchronously_ from `onMount`, it will be called when
270259

271260
<div class="ts-block">
272261

273-
```ts
274-
// @noErrors
262+
```dts
275263
function onMount<T>(
276264
fn: () =>
277265
| NotFunction<T>
@@ -292,8 +280,7 @@ Like lifecycle functions, this must be called during component initialisation.
292280

293281
<div class="ts-block">
294282

295-
```ts
296-
// @noErrors
283+
```dts
297284
function setContext<T>(key: any, context: T): T;
298285
```
299286

@@ -305,8 +292,7 @@ Returns a promise that resolves once any pending state changes have been applied
305292

306293
<div class="ts-block">
307294

308-
```ts
309-
// @noErrors
295+
```dts
310296
function tick(): Promise<void>;
311297
```
312298

@@ -318,8 +304,7 @@ Unmounts a component that was previously mounted using `mount` or `hydrate`.
318304

319305
<div class="ts-block">
320306

321-
```ts
322-
// @noErrors
307+
```dts
323308
function unmount(component: Record<string, any>): void;
324309
```
325310

@@ -333,8 +318,7 @@ https://svelte-5-preview.vercel.app/docs/functions#untrack
333318

334319
<div class="ts-block">
335320

336-
```ts
337-
// @noErrors
321+
```dts
338322
function untrack<T>(fn: () => T): T;
339323
```
340324

apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-animate.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ The flip function calculates the start and end position of an element and animat
1616

1717
<div class="ts-block">
1818

19-
```ts
20-
// @noErrors
19+
```dts
2120
function flip(
2221
node: Element,
2322
{

apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-compiler.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ https://svelte.dev/docs/svelte-compiler#svelte-version
2525

2626
<div class="ts-block">
2727

28-
```ts
29-
// @noErrors
28+
```dts
3029
const VERSION: string;
3130
```
3231

@@ -38,8 +37,7 @@ const VERSION: string;
3837

3938
<div class="ts-block">
4039

41-
```ts
42-
// @noErrors
40+
```dts
4341
function compile(
4442
source: string,
4543
options: CompileOptions
@@ -54,8 +52,7 @@ function compile(
5452

5553
<div class="ts-block">
5654

57-
```ts
58-
// @noErrors
55+
```dts
5956
function compileModule(
6057
source: string,
6158
options: ModuleCompileOptions
@@ -71,8 +68,7 @@ May throw an error if the code is too complex to migrate automatically.
7168

7269
<div class="ts-block">
7370

74-
```ts
75-
// @noErrors
71+
```dts
7672
function migrate(source: string): {
7773
code: string;
7874
};
@@ -89,8 +85,7 @@ The `modern` option (`false` by default in Svelte 5) makes the parser return a m
8985

9086
<div class="ts-block">
9187

92-
```ts
93-
// @noErrors
88+
```dts
9489
function parse(
9590
source: string,
9691
options: {
@@ -104,8 +99,7 @@ function parse(
10499

105100
<div class="ts-block">
106101

107-
```ts
108-
// @noErrors
102+
```dts
109103
function parse(
110104
source: string,
111105
options?:
@@ -126,8 +120,7 @@ For example, it can be used to convert a <style lang="sass"> block into vanilla
126120

127121
<div class="ts-block">
128122

129-
```ts
130-
// @noErrors
123+
```dts
131124
function preprocess(
132125
source: string,
133126
preprocessor: PreprocessorGroup | PreprocessorGroup[],
@@ -147,8 +140,7 @@ function preprocess(
147140

148141
<div class="ts-block">
149142

150-
```ts
151-
// @noErrors
143+
```dts
152144
function walk(): never;
153145
```
154146

0 commit comments

Comments
 (0)