Skip to content

Commit 4eba702

Browse files
committed
docs
1 parent decae2c commit 4eba702

File tree

12 files changed

+91
-18
lines changed

12 files changed

+91
-18
lines changed

packages/docs/src/routes/(routes)/+page.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
23
import Countup from "svelte-countup"
34
import Install from "$components/homepage/Install.svelte"
45
import ComponentsPreview from "$components/homepage/ComponentsPreview.svelte"
@@ -15,7 +16,7 @@
1516
let npm_downloads_count_total = $state(0)
1617
1718
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`)
1920
const data = await response.json()
2021
stargazers_count = data.stargazers_count
2122
dependents_count = data.dependents_count
@@ -117,7 +118,7 @@
117118
// let daisyui5progress = $state(0)
118119
119120
// $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`)
121122
// const data = await response.json()
122123
123124
// let trueCount = 0,

packages/docs/src/routes/(routes)/alternative/[library]/+page.server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
12
import yaml from "js-yaml"
23
import { error } from "@sveltejs/kit"
34

@@ -17,8 +18,8 @@ const fetchYamlData = async (url) => {
1718
}
1819
}
1920

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`)
2223

2324
const getDeterministicIndex = (seedString, maxIndex) => {
2425
if (maxIndex <= 0) return 0

packages/docs/src/routes/(routes)/compare/[item]/+page.server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
12
import yaml from "js-yaml"
23
import { error } from "@sveltejs/kit"
34

45
async function fetchCompareData() {
56
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`)
78

89
if (!response.ok) {
910
throw new Error(`Failed to fetch compare data: ${response.status}`)

packages/docs/src/routes/(routes)/docs/install/+layout.server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
12
import yaml from "js-yaml"
23

34
export async function load() {
45
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`)
67

78
if (!response.ok) {
89
throw new Error(`Failed to fetch frameworks: ${response.status}`)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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!

packages/docs/src/routes/(routes)/docs/roadmap/+page.server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
12
import yaml from "js-yaml"
23

34
export async function load() {
45
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`)
67

78
if (!response.ok) {
89
throw new Error(`Failed to fetch roadmap: ${response.status}`)

packages/docs/src/routes/(routes)/resources/videos/+page.server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
12
export async function load() {
23
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`)
45
if (!response.ok) {
56
throw new Error(`HTTP error! status: ${response.status}`)
67
}

packages/docs/src/routes/(routes)/resources/videos/[id]/+page.server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
12
import { error } from "@sveltejs/kit"
23
import { slugify } from "$lib/util"
34

45
export async function load({ params }) {
56
try {
67
// 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`)
89
if (!response.ok) {
910
throw error(response.status, "Failed to fetch videos")
1011
}

packages/docs/src/routes/(routes)/store/+layout.server.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import yaml from "js-yaml"
1+
import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
22
import { LEMONSQUEEZY_API_KEY } from "$env/static/private"
3+
import yaml from "js-yaml"
34

45
const LSParams = {
56
headers: {
@@ -11,7 +12,7 @@ const LSParams = {
1112

1213
const fetchStoreData = async () => {
1314
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`)
1516

1617
if (!response.ok) {
1718
throw new Error(`Failed to fetch store data: ${response.status}`)
@@ -20,7 +21,7 @@ const fetchStoreData = async () => {
2021
const yamlText = await response.text()
2122
return yaml.load(yamlText)
2223
} 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)
2425
throw error(500, "Server configuration error: Could not load data")
2526
}
2627
}

packages/docs/src/routes/(routes)/store/+page.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
import { PUBLIC_DAISYUI_API_PATH } from "$env/static/public"
23
import { onMount } from "svelte"
34
import SEO from "$components/SEO.svelte"
45
import StoreProduct from "$components/StoreProduct.svelte"
@@ -24,8 +25,8 @@
2425
const fetchDiscount = (async () => {
2526
// Fetch both discount types
2627
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`),
2930
])
3031
3132
// Parse the JSON responses

0 commit comments

Comments
 (0)