Skip to content

Commit

Permalink
setup tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
trusz committed Dec 16, 2024
1 parent 6ca6494 commit 04dd81b
Show file tree
Hide file tree
Showing 8 changed files with 888 additions and 31 deletions.
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,29 @@
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "npm run build && concurrently 'npm:build:watch' 'npm:preview'",
"build": "vite build",
"preview": "vite preview --port 50713",
"build:watch": "npm run build && concurrently 'npm:_build:watch' 'npm:preview'",
"_build:watch": "NODE_ENV=development vite build --watch",
"build:watch": "NODE_ENV=development vite build --watch",
"check": "svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json",
"postinstall": "mkdir -p dist"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@tsconfig/svelte": "^5.0.4",
"autoprefixer": "^10.4.20",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"tailwindcss": "^3.4.9",
"tslib": "^2.6.3",
"typescript": "^5.5.3",
"vite": "^5.4.4"
},
"dependencies": {
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15",
"concurrently": "^8.2.2"
},
"packageManager": "pnpm@9.12.1+sha512.e5a7e52a4183a02d5931057f7a0dbff9d5e9ce3161e33fa68ae392125b79282a8a8a470a51dfc8a0ed86221442eb2fb57019b0990ed24fab519bf0e1bc5ccfc4"
}
}
832 changes: 832 additions & 0 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};
5 changes: 4 additions & 1 deletion src/app.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
h2{
font-family: monospace;
}
}
8 changes: 4 additions & 4 deletions src/plugin.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
editCount: number;
}
let { doc, editCount }: Props = $props();
// let { doc, editCount }: Props = $props();
</script>

{#if doc}
<h2>Welcome to oscd-io-centern</h2>
{/if}

<h2>Welcome to oscd-io-centern</h2>


<input type="hidden" name="package-name" value={pckg.name} />
<input type="hidden" name="package-version" value={pckg.version} />
38 changes: 18 additions & 20 deletions src/plugin.ts → src/plugin.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
import Plugin from './plugin.svelte'
import * as pkg from "../package.json";
import { mount } from "svelte";
import "./app.css";

export default class NewOSCDPlugin extends HTMLElement {

private props = $state<{
doc: XMLDocument | undefined,
editCount: number,
}>({
doc: undefined,
editCount: -1,
});

private plugin?: Plugin

connectedCallback() {
this.attachShadow({ mode: "open" });
this.plugin = mount(Plugin, {
target: this.shadowRoot!,
props: {
doc: this._doc,
editCount: -1
}
});

mount(
Plugin,
{
target: this.shadowRoot!,
// props: this.props,
}
)
const linkElement = createStyleLinkElement()
this.shadowRoot?.appendChild(linkElement)
}

private _doc?: XMLDocument
public set doc(newDoc: XMLDocument){
this._doc = newDoc
if(!this.plugin) {
return
}

this.plugin.$set({doc: newDoc})
this.props.doc = newDoc
}

public set editCount(newCount: number) {
if (!this.plugin) {
return
}
this.plugin.$set({ editCount: newCount })
this.props.editCount = newCount
}

}
Expand Down
14 changes: 14 additions & 0 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import containerQueries from '@tailwindcss/container-queries';
import forms from '@tailwindcss/forms';
import typography from '@tailwindcss/typography';
import type { Config } from 'tailwindcss';

export default {
content: ['./src/**/*.{html,js,svelte,ts}'],

theme: {
extend: {}
},

plugins: [typography, forms, containerQueries]
} satisfies Config;
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { svelte } from '@sveltejs/vite-plugin-svelte'
export default defineConfig({
plugins: [svelte()],
server: {
port: 54187,
port: 49678,
},
build: {
lib: {
entry: "src/plugin.ts",
entry: "src/plugin.svelte.ts",
fileName: "index",
formats: ["es"],
},
Expand Down

0 comments on commit 04dd81b

Please sign in to comment.