Skip to content

Commit

Permalink
feat: create new page for the license
Browse files Browse the repository at this point in the history
  • Loading branch information
findolor committed Oct 23, 2024
1 parent 938f991 commit add67f1
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 5 deletions.
6 changes: 1 addition & 5 deletions tauri-app/src/lib/components/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@
<span data-testid="sidebar-telegram"></span>
</svelte:fragment>
</SidebarItem>
<SidebarItem
label="License"
target="_blank"
href="https://github.com/rainlanguage/decentralicense"
>
<SidebarItem label="License" href="/license">
<svelte:fragment slot="icon">
<FileLinesSolid />
<span data-testid="sidebar-license"></span>
Expand Down
34 changes: 34 additions & 0 deletions tauri-app/src/routes/license/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script>
import Heading from './Heading.svelte';
import Markdown from 'svelte-markdown';
import { onMount } from 'svelte';
import Text from './Text.svelte';
import BlockQuote from './BlockQuote.svelte';
let source = '';
onMount(async () => {
try {
const response = await fetch(
'https://raw.githubusercontent.com/rainlanguage/decentralicense/refs/heads/master/README.md',
);
if (response.ok) {
source = await response.text();
} else {
console.error('Failed to fetch license content');
}
} catch (error) {
console.error('Error fetching license content:', error);
}
});
</script>

<Markdown
{source}
renderers={{
text: Text,
heading: Heading,
blockquote: BlockQuote,
}}
/>
1 change: 1 addition & 0 deletions tauri-app/src/routes/license/BlockQuote.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<blockquote class="p-2 py-1"><slot /></blockquote>
19 changes: 19 additions & 0 deletions tauri-app/src/routes/license/Heading.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script>
export let depth;
</script>

{#if depth === 1}
<div class="mb-4 text-4xl font-medium dark:text-white"><slot /></div>
{:else if depth === 2}
<div class="my-4 text-2xl font-medium dark:text-white"><slot /></div>
{:else if depth === 3}
<div class="my-4 text-xl font-medium dark:text-white"><slot /></div>
{:else if depth === 4}
<div class="my-4 text-lg font-medium dark:text-white"><slot /></div>
{:else if depth === 5}
<h5><slot /></h5>
{:else if depth === 6}
<h6><slot /></h6>
{:else}
<slot />
{/if}
8 changes: 8 additions & 0 deletions tauri-app/src/routes/license/Text.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script>
export let text;
text;
export let raw;
raw;
</script>

<div class="my-2 mb-3"><slot /></div>

0 comments on commit add67f1

Please sign in to comment.