File tree Expand file tree Collapse file tree 12 files changed +91
-18
lines changed Expand file tree Collapse file tree 12 files changed +91
-18
lines changed Original file line number Diff line number Diff line change 1
1
<script >
2
+ import { PUBLIC_DAISYUI_API_PATH } from " $env/static/public"
2
3
import Countup from " svelte-countup"
3
4
import Install from " $components/homepage/Install.svelte"
4
5
import ComponentsPreview from " $components/homepage/ComponentsPreview.svelte"
15
16
let npm_downloads_count_total = $state (0 )
16
17
17
18
async function fetchStats () {
18
- const response = await fetch (" https://api.daisyui.com/ stats.json" )
19
+ const response = await fetch (` ${ PUBLIC_DAISYUI_API_PATH } / stats.json` )
19
20
const data = await response .json ()
20
21
stargazers_count = data .stargazers_count
21
22
dependents_count = data .dependents_count
117
118
// let daisyui5progress = $state(0)
118
119
119
120
// $effect(async () => {
120
- // const response = await fetch("https:// api.daisyui.com/api/ progress.json" )
121
+ // const response = await fetch(`${PUBLIC_DAISYUI_API_PATH}/ api/ progress.json` )
121
122
// const data = await response.json()
122
123
123
124
// let trueCount = 0,
Original file line number Diff line number Diff line change
1
+ import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
1
2
import yaml from "js-yaml"
2
3
import { error } from "@sveltejs/kit"
3
4
@@ -17,8 +18,8 @@ const fetchYamlData = async (url) => {
17
18
}
18
19
}
19
20
20
- const fetchAlternativeData = ( ) => fetchYamlData ( "https://api.daisyui.com/ data/alternative.yaml" )
21
- const fetchCompareData = ( ) => fetchYamlData ( "https://api.daisyui.com/ data/compare.yaml" )
21
+ const fetchAlternativeData = ( ) => fetchYamlData ( ` ${ PUBLIC_DAISYUI_API_PATH } / data/alternative.yaml` )
22
+ const fetchCompareData = ( ) => fetchYamlData ( ` ${ PUBLIC_DAISYUI_API_PATH } / data/compare.yaml` )
22
23
23
24
const getDeterministicIndex = ( seedString , maxIndex ) => {
24
25
if ( maxIndex <= 0 ) return 0
Original file line number Diff line number Diff line change
1
+ import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
1
2
import yaml from "js-yaml"
2
3
import { error } from "@sveltejs/kit"
3
4
4
5
async function fetchCompareData ( ) {
5
6
try {
6
- const response = await fetch ( "https://api.daisyui.com/ data/compare.yaml" )
7
+ const response = await fetch ( ` ${ PUBLIC_DAISYUI_API_PATH } / data/compare.yaml` )
7
8
8
9
if ( ! response . ok ) {
9
10
throw new Error ( `Failed to fetch compare data: ${ response . status } ` )
Original file line number Diff line number Diff line change
1
+ import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
1
2
import yaml from "js-yaml"
2
3
3
4
export async function load ( ) {
4
5
try {
5
- const response = await fetch ( "https://api.daisyui.com/ data/frameworks.yaml" )
6
+ const response = await fetch ( ` ${ PUBLIC_DAISYUI_API_PATH } / data/frameworks.yaml` )
6
7
7
8
if ( ! response . ok ) {
8
9
throw new Error ( `Failed to fetch frameworks: ${ response . status } ` )
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : Install daisyUI for Lit
3
+ desc : How to install Tailwind CSS and daisyUI in a Lit + Vite project
4
+ ---
5
+
6
+ <script >
7
+ import Translate from " $components/Translate.svelte"
8
+ </script >
9
+
10
+ ### 1. Create a new Vite project
11
+
12
+ Create a new Vite project in the current directory
13
+
14
+ ``` sh:Terminal
15
+ npm create vite@latest ./ -- --template lit
16
+ ```
17
+
18
+ ### 2. Install Tailwind CSS and daisyUI
19
+
20
+ ``` sh:Terminal
21
+ npm install tailwindcss@latest @tailwindcss/vite@latest daisyui@latest
22
+ ```
23
+
24
+ Add Tailwind CSS to Vite config
25
+
26
+ ``` js:vite.config.js
27
+ import { defineConfig } from ' vite' ;
28
+ import tailwindcss from ' @tailwindcss/vite' ;
29
+
30
+ export default defineConfig ({
31
+ plugins: [
32
+ tailwindcss ()
33
+ ],
34
+ });
35
+ ```
36
+
37
+ Put Tailwind CSS and daisyUI in your CSS file (and remove old styles)
38
+
39
+ ``` postcss:src/index.css
40
+ @import " tailwindcss" ;
41
+ @plugin "daisyui";
42
+ ```
43
+
44
+ ### 3. Make the CSS available for shadow DOM elements
45
+
46
+ Put this code in ` src/my-element.js ` file and remove the old code
47
+ ``` js:src/my-element.js
48
+ import { LitElement , html } from " lit" ;
49
+ import { unsafeCSS } from " lit" ;
50
+ import globalStyles from " ./index.css?inline" ;
51
+
52
+ export class MyElement extends LitElement {
53
+ static styles = [unsafeCSS (globalStyles)];
54
+ render () {
55
+ return html ` <button class =" btn" >daisyUI button</button > ` ;
56
+ }
57
+ }
58
+
59
+ window .customElements .define (" my-element" , MyElement);
60
+ ```
61
+
62
+ Now you can use daisyUI class names!
Original file line number Diff line number Diff line change
1
+ import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
1
2
import yaml from "js-yaml"
2
3
3
4
export async function load ( ) {
4
5
try {
5
- const response = await fetch ( "https://api.daisyui.com/ data/roadmap.yaml" )
6
+ const response = await fetch ( ` ${ PUBLIC_DAISYUI_API_PATH } / data/roadmap.yaml` )
6
7
7
8
if ( ! response . ok ) {
8
9
throw new Error ( `Failed to fetch roadmap: ${ response . status } ` )
Original file line number Diff line number Diff line change
1
+ import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
1
2
export async function load ( ) {
2
3
try {
3
- const response = await fetch ( "https:// api.daisyui.com/api/ youtube.json" )
4
+ const response = await fetch ( ` ${ PUBLIC_DAISYUI_API_PATH } / api/ youtube.json` )
4
5
if ( ! response . ok ) {
5
6
throw new Error ( `HTTP error! status: ${ response . status } ` )
6
7
}
Original file line number Diff line number Diff line change
1
+ import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
1
2
import { error } from "@sveltejs/kit"
2
3
import { slugify } from "$lib/util"
3
4
4
5
export async function load ( { params } ) {
5
6
try {
6
7
// Fetch videos from API endpoint
7
- const response = await fetch ( "https:// api.daisyui.com/api/ youtube.json" )
8
+ const response = await fetch ( ` ${ PUBLIC_DAISYUI_API_PATH } / api/ youtube.json` )
8
9
if ( ! response . ok ) {
9
10
throw error ( response . status , "Failed to fetch videos" )
10
11
}
Original file line number Diff line number Diff line change 1
- import yaml from "js-yaml "
1
+ import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public "
2
2
import { LEMONSQUEEZY_API_KEY } from "$env/static/private"
3
+ import yaml from "js-yaml"
3
4
4
5
const LSParams = {
5
6
headers : {
@@ -11,7 +12,7 @@ const LSParams = {
11
12
12
13
const fetchStoreData = async ( ) => {
13
14
try {
14
- const response = await fetch ( "https://api.daisyui.com/ data/store.yaml" )
15
+ const response = await fetch ( ` ${ PUBLIC_DAISYUI_API_PATH } / data/store.yaml` )
15
16
16
17
if ( ! response . ok ) {
17
18
throw new Error ( `Failed to fetch store data: ${ response . status } ` )
@@ -20,7 +21,7 @@ const fetchStoreData = async () => {
20
21
const yamlText = await response . text ( )
21
22
return yaml . load ( yamlText )
22
23
} catch ( e ) {
23
- console . error ( `Error loading or parsing YAML from https://api.daisyui.com/data/store.yaml ` , e )
24
+ console . error ( `Error loading or parsing YAML` , e )
24
25
throw error ( 500 , "Server configuration error: Could not load data" )
25
26
}
26
27
}
Original file line number Diff line number Diff line change 1
1
<script >
2
+ import { PUBLIC_DAISYUI_API_PATH } from " $env/static/public"
2
3
import { onMount } from " svelte"
3
4
import SEO from " $components/SEO.svelte"
4
5
import StoreProduct from " $components/StoreProduct.svelte"
24
25
const fetchDiscount = (async () => {
25
26
// Fetch both discount types
26
27
const [shorttimeDiscountResponse , specialDiscountResponse ] = await Promise .all ([
27
- fetch (" https:// api.daisyui.com/api/ discount_shorttime.json" ),
28
- fetch (" https:// api.daisyui.com/api/ discount_special.json" ),
28
+ fetch (` ${ PUBLIC_DAISYUI_API_PATH } / api/ discount_shorttime.json` ),
29
+ fetch (` ${ PUBLIC_DAISYUI_API_PATH } / api/ discount_special.json` ),
29
30
])
30
31
31
32
// Parse the JSON responses
You can’t perform that action at this time.
0 commit comments