-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
787b1e0
commit 37d1c86
Showing
89 changed files
with
655 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script lang="ts"> | ||
import Header from '$lib/layout/Header.svelte'; | ||
import Svg from './Svg.svelte'; | ||
import link from 'bootstrap-icons/icons/link-45deg.svg?raw'; | ||
export let depth: 1 | 2 | 3 | 4 | 5 | 6; | ||
export let text: string; | ||
export let id: string = text.toLowerCase().replace(/\s/g, '-').trim(); | ||
export let headerClassName: string | undefined = undefined; | ||
</script> | ||
|
||
{#if depth > 1} | ||
<svelte:element this={'h' + depth} {id} class={headerClassName}> | ||
{text} | ||
<a class="anchor-link" href="#{id}" aria-label="link to {text}"><Svg className="icon-24 align-middle" svg={link} /></a> | ||
</svelte:element> | ||
{:else} | ||
<Header title={text} /> | ||
{/if} | ||
|
||
<style lang="scss"> | ||
.anchor-link { | ||
text-decoration: none; | ||
opacity: 0; | ||
transition: opacity 0.15s ease-in-out; | ||
&:focus, | ||
&:hover, | ||
:hover > &, | ||
:target > & { | ||
opacity: 1; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,13 @@ | ||
<script lang="ts"> | ||
import Svg from './Svg.svelte'; | ||
import link from 'bootstrap-icons/icons/link-45deg.svg?raw'; | ||
import Heading from '$lib/layout/Heading.svelte'; | ||
export let level: 1 | 2 | 3; | ||
export let label: string; | ||
export let id: string; | ||
export let id: string = label.toLowerCase().replace(/\s/g, '-').trim(); | ||
export let headerClassName: string | undefined = undefined; | ||
</script> | ||
|
||
<section> | ||
<svelte:element this={'h' + level} {id} class={headerClassName}> | ||
{label} | ||
<a class="anchor-link" href="#{id}" aria-label="link to {label}"><Svg className="icon-24 align-middle" svg={link} /></a> | ||
</svelte:element> | ||
<Heading depth={level} text={label} {id} {headerClassName} /> | ||
<slot /> | ||
</section> | ||
|
||
<style lang="scss"> | ||
.anchor-link { | ||
text-decoration: none; | ||
opacity: 0; | ||
transition: opacity 0.15s ease-in-out; | ||
&:focus, | ||
&:hover, | ||
:hover > &, | ||
:target > & { | ||
opacity: 1; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<script lang="ts"> | ||
import SvelteMarkdown, {type Renderers} from 'svelte-markdown'; | ||
import Heading from '$lib/layout/Heading.svelte'; | ||
import MdCode from '$lib/markdown/renderers/MdCode.svelte'; | ||
import {marked} from 'marked'; | ||
import MdSection from '$lib/markdown/renderers/MdSection.svelte'; | ||
import MdImage from '$lib/markdown/renderers/MdImage.svelte'; | ||
export let source: string; | ||
function getTokens(src: string) { | ||
const tokens = marked.lexer(src); | ||
const walkTokens = (tokens: marked.TokensList | marked.Token[]) => { | ||
let indexLastHeading = -1; | ||
for (let i = 0; i < tokens.length; i++) { | ||
const token = tokens[i]; | ||
if ((token as marked.Tokens.Generic).tokens?.length) { | ||
walkTokens((token as marked.Tokens.Generic).tokens!); | ||
} | ||
if (token.type === 'heading' && token.depth === 2) { | ||
if (indexLastHeading >= 0) { | ||
tokens.splice(indexLastHeading, i - indexLastHeading, { | ||
type: 'section', | ||
tokens: tokens.slice(indexLastHeading, i), | ||
} as unknown as marked.Token); | ||
i = indexLastHeading + 1; | ||
} | ||
indexLastHeading = i; | ||
} | ||
} | ||
if (indexLastHeading >= 0) { | ||
tokens.splice(indexLastHeading, tokens.length - indexLastHeading, { | ||
type: 'section', | ||
tokens: tokens.slice(indexLastHeading, tokens.length), | ||
} as unknown as marked.Token); | ||
} | ||
}; | ||
walkTokens(tokens); | ||
return tokens; | ||
} | ||
$: tokens = getTokens(source); | ||
const renderers: Partial<Renderers> = {image: MdImage, heading: Heading, code: MdCode, section: MdSection} as Partial<Renderers>; | ||
</script> | ||
|
||
<SvelteMarkdown source={tokens} {renderers} /> |
1 change: 1 addition & 0 deletions
1
demo/src/lib/markdown/code/install-bootstrap/install-bootstrap-angular.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm install @agnos-ui/angular |
1 change: 1 addition & 0 deletions
1
demo/src/lib/markdown/code/install-bootstrap/install-bootstrap-react.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm install @agnos-ui/react |
1 change: 1 addition & 0 deletions
1
demo/src/lib/markdown/code/install-bootstrap/install-bootstrap-svelte.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm install @agnos-ui/svelte |
1 change: 1 addition & 0 deletions
1
demo/src/lib/markdown/code/install-headless/install-headless-angular.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm install @agnos-ui/angular-headless |
1 change: 1 addition & 0 deletions
1
demo/src/lib/markdown/code/install-headless/install-headless-react.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm install @agnos-ui/react-headless |
1 change: 1 addition & 0 deletions
1
demo/src/lib/markdown/code/install-headless/install-headless-svelte.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm install @agnos-ui/svelte-headless |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<script lang="ts"> | ||
import Code from '$lib/layout/Code.svelte'; | ||
import Sample from '$lib/layout/Sample.svelte'; | ||
import type {SampleInfo} from '$lib/layout/sample'; | ||
import {selectedFramework$} from '$lib/stores'; | ||
import samples from '../samples'; | ||
export let lang: string; | ||
export let text: string; | ||
let code = ''; | ||
let title: string; | ||
let sample: SampleInfo; | ||
let height = 500; | ||
const extensions: Map<string, string> = new Map(); | ||
extensions.set('typescript', 'ts'); | ||
extensions.set('bash', 'sh'); | ||
async function getCode(text: string, selectedFramework: string, lang: string) { | ||
if (lang !== 'sample' && text.trim().match(/^\{[a-z-]+\}$/) && extensions.has(lang)) { | ||
const codeKey = text.trim().slice(1, -1); | ||
code = (await import(`$lib/markdown/code/${codeKey}/${codeKey}-${selectedFramework}.${extensions.get(lang)}?raw`)).default; | ||
} else { | ||
code = text.trim(); | ||
} | ||
} | ||
async function getSample(text: string, lang: string) { | ||
if (lang === 'sample') { | ||
const match = text.trim().match(/^\{([^:]+):([a-z-/]+):(\d+)\}$/); | ||
if (match) { | ||
title = match[1]; | ||
const sampleKey = match[2]; | ||
height = Number.parseInt(match[3], 10); | ||
if (samples.has(sampleKey)) { | ||
sample = samples.get(sampleKey)!; | ||
} | ||
} | ||
} | ||
} | ||
$: void getCode(text, $selectedFramework$, lang); | ||
$: void getSample(text, lang); | ||
</script> | ||
|
||
{#if lang === 'sample'} | ||
{#if sample} | ||
<Sample {title} {sample} {height} /> | ||
{:else} | ||
Sample not found, make sure to fill the samples.ts file. | ||
{/if} | ||
{:else} | ||
<Code language={lang} {code} /> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script lang="ts"> | ||
export let href = ''; | ||
export let title: string; | ||
export let text = ''; | ||
let src: string; | ||
async function getSrc(href: string) { | ||
src = (await import(`../../../resources/images/${href.slice(href.indexOf('resources/images/') + 17, -5)}.webp`)).default; | ||
} | ||
$: void getSrc(href); | ||
</script> | ||
|
||
<img {src} {title} alt={text} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<section><slot /></section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type {SampleInfo} from '$lib/layout/sample'; | ||
|
||
import focustrack from '@agnos-ui/samples/focustrack/focustrack'; | ||
|
||
const samples: Map<string, SampleInfo> = new Map(); | ||
samples.set('focustrack/focustrack', focustrack); | ||
|
||
export default samples; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.