Skip to content

Commit 5810d97

Browse files
committed
add d-container component, move app.vue to app folder
1 parent 1cd0ca5 commit 5810d97

File tree

8 files changed

+112
-1
lines changed

8 files changed

+112
-1
lines changed

.playground/app/components.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ declare module 'vue' {
1313
IFa6SolidTrash: typeof import('~icons/fa6-solid/trash')['default']
1414
NButton: typeof import('naive-ui')['NButton']
1515
NCheckbox: typeof import('naive-ui')['NCheckbox']
16+
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
1617
NDatePicker: typeof import('naive-ui')['NDatePicker']
18+
NDialogProvider: typeof import('naive-ui')['NDialogProvider']
1719
NEmpty: typeof import('naive-ui')['NEmpty']
1820
NInput: typeof import('naive-ui')['NInput']
1921
NSelect: typeof import('naive-ui')['NSelect']

.playground/app/pages/index.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@
5656
</div>
5757
</div>
5858
</n-tab-pane>
59+
<n-tab-pane name="grid" tab="Grid">
60+
<d-container :max-columns="5">
61+
<input class="bg-white" type="text">
62+
<input class="bg-white" type="text">
63+
<input class="bg-white" type="text">
64+
<input class="bg-white" type="text">
65+
<input class="bg-white" type="text">
66+
<input class="bg-white" type="text">
67+
</d-container>
68+
</n-tab-pane>
5969
</n-tabs>
6070
<div class="toggle-theme cursor-pointer p-2 border border-main-brand rounded inline-block absolute -top-1 right-2" @click="toggleTheme()">
6171
<IFa6SolidSun v-if="themeName === 'dark'" width="1.1rem" height="1.1rem" class="toggle-theme-sun"/>

app.vue renamed to app/app.vue

File renamed without changes.

app/components/DContainer.vue

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<div class="grid mx-auto w-full" :style="[gridStyle, { columnGap: props.gapX, rowGap: props.gapY, gap: props.gap, }]">
3+
<slot/>
4+
</div>
5+
</template>
6+
7+
<script setup lang="ts">
8+
type Props = {
9+
minColumns?: number,
10+
maxColumns?: number,
11+
gap?: string,
12+
gapX?: string,
13+
gapY?: string
14+
}
15+
16+
const props = withDefaults(defineProps<Props>(), {
17+
minColumns: 2,
18+
maxColumns: 4,
19+
gap: '1rem'
20+
})
21+
22+
const { width } = useWindowSize()
23+
const childCount = (useSlots()?.default?.({}) || []).length
24+
25+
const gridStyle = computed(() => {
26+
let c = Math.min(props.maxColumns, Math.max(props.minColumns, childCount))
27+
28+
if (width.value < 640) c = 1
29+
else if (width.value < 768) c = Math.min(c, 2)
30+
31+
return `grid-template-columns: repeat(${c}, minmax(0, 1fr))`
32+
})
33+
</script>

app/components/NaiveUIWrapper.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const props = withDefaults(
3131
3232
const isLoaded = ref(false)
3333
const { themeUI } = useTheme({ naiveUIStyles: props.theme })
34+
console.log(themeUI.value);
35+
3436
3537
onMounted(() => {
3638
isLoaded.value = true

nuxt.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ export default defineNuxtConfig({
2020
},
2121
css: ['./app/assets/tailwind.css'],
2222
devtools: { enabled: true },
23-
modules: ['nuxtjs-naive-ui', 'unplugin-icons/nuxt', '@nuxtjs/google-fonts', 'nuxt-file-storage'],
23+
modules: [
24+
'nuxtjs-naive-ui',
25+
'unplugin-icons/nuxt',
26+
'@nuxtjs/google-fonts',
27+
'nuxt-file-storage',
28+
'@vueuse/nuxt'
29+
],
2430
vite: {
2531
optimizeDeps: {
2632
include:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@nuxtjs/google-fonts": "^3.2.0",
3838
"@tailwindcss/vite": "4.0.0-beta.8",
3939
"@vueuse/core": "^12.3.0",
40+
"@vueuse/nuxt": "^12.4.0",
4041
"ansis": "^3.6.0",
4142
"boxen": "^8.0.1",
4243
"cyrillic-to-translit-js": "^3.2.1",

pnpm-lock.yaml

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)