Skip to content

Commit

Permalink
feat: added global components
Browse files Browse the repository at this point in the history
  • Loading branch information
bbtgnn committed Mar 1, 2024
1 parent 1cc862b commit 758f705
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"workbench.colorTheme": "Material Theme High Contrast",
"workbench.colorCustomizations": {
"[Material Theme Palenight High Contrast]": {}
},
"svelte.plugin.svelte.compilerWarnings": {
"missing-declaration": "ignore"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"build": "vite build",
"preview": "vite preview",
"test": "npm run test:integration && npm run test:unit",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --compiler-warnings 'missing-declaration:ignore'",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch --compiler-warnings 'missing-declaration:ignore'",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"test:integration": "playwright test",
Expand Down
7 changes: 5 additions & 2 deletions src/_modules/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Document from './Document.svelte';
import _ from 'lodash';

import Doc from './Document.svelte';
import DocumentContent from './DocumentContent.svelte';
import Collection from './Collection.svelte';
import Relation from './Relation.svelte';
import LogBanner from './LogBanner.svelte';

export { Document, DocumentContent, Collection, Relation, LogBanner };
_.assign(globalThis, { Doc });
export { Doc, DocumentContent, Collection, Relation, LogBanner };
4 changes: 4 additions & 0 deletions src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Doc as DocComponent } from '$modules/components';

// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
Expand All @@ -8,6 +10,8 @@ declare global {
// interface PageState {}
// interface Platform {}
}

const Doc: typeof DocComponent;
}

export {};
5 changes: 2 additions & 3 deletions src/routes/(database)/organizations/dyne/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts" context="module">
import { db } from '$modules';
import { Document } from '$modules/components';
import logo from './logo.jpeg';
export const props = db.create('organizations', {
Expand All @@ -13,7 +12,7 @@
<p>Mo bellissima dyne</p>
<img src="./logo.jpeg" alt="dyne logo" />

<Document collection="organizations" name="freelance" let:doc>
<Doc collection="organizations" name="freelance" let:doc>
<pre>{JSON.stringify(doc, null, 2)}</pre>
</Document>
</Doc>
<img src={logo} alt="dyne logo" />
6 changes: 3 additions & 3 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { Collection, Document, Relation } from '$modules/components';
import { Collection, Relation } from '$modules/components';
import DocumentContent from '$modules/components/DocumentContent.svelte';
import { db } from '$modules/index';
import { href } from '$modules/utils';
Expand All @@ -17,10 +17,10 @@
<div>
<a href={href('/cv')} class="button">CV</a>

<Document collection="organizations" name="dyne" let:doc>
<Doc collection="organizations" name="dyne" let:doc>
<pre>{JSON.stringify(doc)}</pre>
<img alt="ciao" src={doc.props?.logo} />
</Document>
</Doc>

<hr />

Expand Down
15 changes: 5 additions & 10 deletions src/routes/cv/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import Collection from '$modules/components/Collection.svelte';
import Document from '$modules/components/Document.svelte';
import Relation from '$modules/components/Relation.svelte';
import { href } from '$modules/utils';
import { formatDate } from 'date-fns/format';
Expand All @@ -15,13 +14,13 @@
{#if document.props?.current}
<div class="rounded-xl border border-stone-300 p-4">
<p>{document.props.roles.join(', ')}</p>
<Document
<Doc
collection={document.props.employer.collection}
name={document.props.employer.document}
let:doc
>
<p>{doc.props?.name}</p>
</Document>
</Doc>
<p>
<span>
{formatDate(document.props.date_start, 'MM / yyyy')}
Expand All @@ -30,7 +29,7 @@
<span> oggi </span>
</p>
</div>
<!-- <pre>{JSON.stringify(document, null, 2)}</pre> -->
<Doc collection="education" name="triennio-isia-urbino"></Doc>
{/if}
{/each}

Expand All @@ -39,13 +38,9 @@
{#if document.props?.date_end}
<div class="rounded-xl border border-stone-300 p-4">
<p>{document.props.roles.join(', ')}</p>
<Document
collection={document.props.employer.collection}
name={document.props.employer.document}
let:doc
>
<Doc collection="organizations" name={document.props.employer.document} let:doc>
<p>{doc.props?.name}</p>
</Document>
</Doc>
<p>
<span>
{formatDate(document.props.date_start, 'MM / yyyy')}
Expand Down

0 comments on commit 758f705

Please sign in to comment.