mirror of
https://github.com/HoshinoSuzumi/rayine-ui.git
synced 2025-04-10 04:58:51 +08:00
🎨 chore: reformat code
This commit is contained in:
parent
d9ad42dfa1
commit
09a5faa361
@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { camelCase, upperFirst } from 'scule';
|
import { camelCase, upperFirst } from 'scule'
|
||||||
import * as config from '#rayui/ui.config'
|
import * as config from '#rayui/ui.config'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
@ -31,11 +31,11 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
type: Array as PropType<{ name: string, values: string[], restriction: 'expected' | 'included' | 'excluded' | 'only' }[]>,
|
type: Array as PropType<{ name: string, values: string[], restriction: 'expected' | 'included' | 'excluded' | 'only' }[]>,
|
||||||
default: () => []
|
default: () => [],
|
||||||
},
|
},
|
||||||
excludedProps: {
|
excludedProps: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => [],
|
||||||
},
|
},
|
||||||
filename: {
|
filename: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -110,7 +110,7 @@ const customizableProps = computed(() => Object.keys(componentProps).map((k) =>
|
|||||||
label: camelCase(k),
|
label: camelCase(k),
|
||||||
options,
|
options,
|
||||||
}
|
}
|
||||||
}).filter((prop) => prop !== null))
|
}).filter(prop => prop !== null))
|
||||||
|
|
||||||
const code = computed(() => {
|
const code = computed(() => {
|
||||||
let code = `\`\`\`html
|
let code = `\`\`\`html
|
||||||
@ -145,23 +145,36 @@ const { data: codeRender, error: codeRenderError } = await useAsyncData(`${compo
|
|||||||
|
|
||||||
<div :class="['p-4 overflow-auto', !!codeRender ? 'border-b border-neutral-200 dark:border-neutral-700' : '']">
|
<div :class="['p-4 overflow-auto', !!codeRender ? 'border-b border-neutral-200 dark:border-neutral-700' : '']">
|
||||||
<component :is="componentName" v-bind="componentProps">
|
<component :is="componentName" v-bind="componentProps">
|
||||||
<slot></slot>
|
<slot />
|
||||||
</component>
|
</component>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="customizableProps.length > 0" class="border-b border-neutral-200 dark:border-neutral-700 flex">
|
<div v-if="customizableProps.length > 0" class="border-b border-neutral-200 dark:border-neutral-700 flex">
|
||||||
<div v-for="(prop, k) in customizableProps" :key="k"
|
<div
|
||||||
class="px-2 py-0.5 flex flex-col gap-0.5 border-r dark:border-neutral-700">
|
v-for="(prop, k) in customizableProps"
|
||||||
|
:key="k"
|
||||||
|
class="px-2 py-0.5 flex flex-col gap-0.5 border-r dark:border-neutral-700"
|
||||||
|
>
|
||||||
<label :for="`${prop.name}-prop`" class="text-sm text-neutral-400">{{ prop.name }}</label>
|
<label :for="`${prop.name}-prop`" class="text-sm text-neutral-400">{{ prop.name }}</label>
|
||||||
<input v-if="prop.type.startsWith('boolean')" :id="`${prop.name}-prop`" v-model="componentProps[prop.name]"
|
<input
|
||||||
type="checkbox" class="mt-1 mb-2">
|
v-if="prop.type.startsWith('boolean')"
|
||||||
|
:id="`${prop.name}-prop`"
|
||||||
|
v-model="componentProps[prop.name]"
|
||||||
|
type="checkbox"
|
||||||
|
class="mt-1 mb-2"
|
||||||
|
>
|
||||||
<select v-else-if="prop.options.length" :id="`${prop.name}-prop`" v-model="componentProps[prop.name]">
|
<select v-else-if="prop.options.length" :id="`${prop.name}-prop`" v-model="componentProps[prop.name]">
|
||||||
<option v-for="option in prop.options" :key="option" :value="option">
|
<option v-for="option in prop.options" :key="option" :value="option">
|
||||||
{{ option }}
|
{{ option }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<input v-else :id="`${prop.name}-prop`" v-model="componentProps[prop.name]" type="text"
|
<input
|
||||||
placeholder="type something...">
|
v-else
|
||||||
|
:id="`${prop.name}-prop`"
|
||||||
|
v-model="componentProps[prop.name]"
|
||||||
|
type="text"
|
||||||
|
placeholder="type something..."
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -38,8 +38,11 @@ const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
|
|||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<ul v-if="link.children" class="pl-4 pt-2 space-y-1">
|
<ul v-if="link.children" class="pl-4 pt-2 space-y-1">
|
||||||
<li v-for="child in link.children" :key="child._path">
|
<li v-for="child in link.children" :key="child._path">
|
||||||
<NuxtLink :to="child._path" class="text-sm text-neutral-500 dark:text-neutral-400"
|
<NuxtLink
|
||||||
active-class="text-primary font-medium">
|
:to="child._path"
|
||||||
|
class="text-sm text-neutral-500 dark:text-neutral-400"
|
||||||
|
active-class="text-primary font-medium"
|
||||||
|
>
|
||||||
{{ child.title }}
|
{{ child.title }}
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</li>
|
</li>
|
||||||
@ -65,7 +68,8 @@ const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="w-full flex justify-between gap-4 mt-12 pt-12 border-t border-t-neutral-200 dark:border-t-neutral-700">
|
class="w-full flex justify-between gap-4 mt-12 pt-12 border-t border-t-neutral-200 dark:border-t-neutral-700"
|
||||||
|
>
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<NuxtLink v-if="surround?.[0]" :to="surround[0]._path" class="surround-btn">
|
<NuxtLink v-if="surround?.[0]" :to="surround[0]._path" class="surround-btn">
|
||||||
<div>
|
<div>
|
||||||
@ -89,14 +93,14 @@ const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
|
|||||||
|
|
||||||
<div v-if="hasToc" class="hidden" :class="{ 'col-span-2 md:block': hasToc }">
|
<div v-if="hasToc" class="hidden" :class="{ 'col-span-2 md:block': hasToc }">
|
||||||
<div
|
<div
|
||||||
class="bg-neutral-50 dark:bg-neutral-800/50 rounded-lg px-4 py-3 overflow-hidden overflow-y-auto sticky top-[calc(64px+16px)]">
|
class="bg-neutral-50 dark:bg-neutral-800/50 rounded-lg px-4 py-3 overflow-hidden overflow-y-auto sticky top-[calc(64px+16px)]"
|
||||||
|
>
|
||||||
<span class="text-xs text-neutral-600 dark:text-neutral-300 font-medium inline-block mb-2">
|
<span class="text-xs text-neutral-600 dark:text-neutral-300 font-medium inline-block mb-2">
|
||||||
Table of contents
|
Table of contents
|
||||||
</span>
|
</span>
|
||||||
<Toc :toc="page!.body!.toc!.links" />
|
<Toc :toc="page!.body!.toc!.links" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
2
src/runtime/types/message.d.ts
vendored
2
src/runtime/types/message.d.ts
vendored
@ -1,6 +1,6 @@
|
|||||||
|
import type { AppConfig } from 'nuxt/schema'
|
||||||
import type { message } from '../ui.config'
|
import type { message } from '../ui.config'
|
||||||
import type colors from '#ray-colors'
|
import type colors from '#ray-colors'
|
||||||
import type { AppConfig } from 'nuxt/schema';
|
|
||||||
|
|
||||||
export type MessageType = keyof typeof message.type
|
export type MessageType = keyof typeof message.type
|
||||||
export type MessageColor = (typeof colors)[number]
|
export type MessageColor = (typeof colors)[number]
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
export default {
|
export default {
|
||||||
wrapper: "mx-auto w-fit pointer-events-auto",
|
wrapper: 'mx-auto w-fit pointer-events-auto',
|
||||||
container: "px-2 py-1.5 border flex items-center gap-1.5",
|
container: 'px-2 py-1.5 border flex items-center gap-1.5',
|
||||||
shadow: "shadow-md shadow-{color}-100 dark:shadow-{color}-900",
|
shadow: 'shadow-md shadow-{color}-100 dark:shadow-{color}-900',
|
||||||
rounded: "rounded-md",
|
rounded: 'rounded-md',
|
||||||
border: "border-{color}-400 dark:border-{color}-600",
|
border: 'border-{color}-400 dark:border-{color}-600',
|
||||||
background: "bg-{color}-50 dark:bg-{color}-900",
|
background: 'bg-{color}-50 dark:bg-{color}-900',
|
||||||
content: "text-xs font-sans font-bold text-{color}-500 dark:text-{color}-300",
|
content: 'text-xs font-sans font-bold text-{color}-500 dark:text-{color}-300',
|
||||||
type: {
|
type: {
|
||||||
success: {
|
success: {
|
||||||
color: "emerald",
|
color: 'emerald',
|
||||||
},
|
},
|
||||||
warning: {
|
warning: {
|
||||||
color: "amber",
|
color: 'amber',
|
||||||
},
|
},
|
||||||
error: {
|
error: {
|
||||||
color: "red",
|
color: 'red',
|
||||||
},
|
},
|
||||||
info: {
|
info: {
|
||||||
color: "blue",
|
color: 'blue',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: {
|
default: {
|
||||||
@ -25,4 +25,4 @@ export default {
|
|||||||
color: 'primary',
|
color: 'primary',
|
||||||
duration: 4000,
|
duration: 4000,
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
|
@ -63,105 +63,105 @@ export const setColors = (theme: TwConfig['theme']) => {
|
|||||||
|
|
||||||
const safelistForComponent: Record<
|
const safelistForComponent: Record<
|
||||||
string,
|
string,
|
||||||
(colors: string) => TwConfig["safelist"]
|
(colors: string) => TwConfig['safelist']
|
||||||
> = {
|
> = {
|
||||||
button: (colorsToRegex) => [
|
button: colorsToRegex => [
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^bg-(${colorsToRegex})-50$`),
|
pattern: RegExp(`^bg-(${colorsToRegex})-50$`),
|
||||||
variants: ["hover", "disabled"],
|
variants: ['hover', 'disabled'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^bg-(${colorsToRegex})-100$`),
|
pattern: RegExp(`^bg-(${colorsToRegex})-100$`),
|
||||||
variants: ["hover"],
|
variants: ['hover'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^bg-(${colorsToRegex})-400$`),
|
pattern: RegExp(`^bg-(${colorsToRegex})-400$`),
|
||||||
variants: ["dark", "dark:disabled"],
|
variants: ['dark', 'dark:disabled'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^bg-(${colorsToRegex})-500$`),
|
pattern: RegExp(`^bg-(${colorsToRegex})-500$`),
|
||||||
variants: ["disabled", "dark:hover", "dark:active"],
|
variants: ['disabled', 'dark:hover', 'dark:active'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^bg-(${colorsToRegex})-600$`),
|
pattern: RegExp(`^bg-(${colorsToRegex})-600$`),
|
||||||
variants: ["hover"],
|
variants: ['hover'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^bg-(${colorsToRegex})-700$`),
|
pattern: RegExp(`^bg-(${colorsToRegex})-700$`),
|
||||||
variants: ["active"],
|
variants: ['active'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^bg-(${colorsToRegex})-900$`),
|
pattern: RegExp(`^bg-(${colorsToRegex})-900$`),
|
||||||
variants: ["dark:hover"],
|
variants: ['dark:hover'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^bg-(${colorsToRegex})-950$`),
|
pattern: RegExp(`^bg-(${colorsToRegex})-950$`),
|
||||||
variants: ["dark", "dark:hover", "dark:disabled"],
|
variants: ['dark', 'dark:hover', 'dark:disabled'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^text-(${colorsToRegex})-400$`),
|
pattern: RegExp(`^text-(${colorsToRegex})-400$`),
|
||||||
variants: ["dark", "dark:hover", "dark:disabled"],
|
variants: ['dark', 'dark:hover', 'dark:disabled'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^text-(${colorsToRegex})-500$`),
|
pattern: RegExp(`^text-(${colorsToRegex})-500$`),
|
||||||
variants: ["dark:hover", "disabled"],
|
variants: ['dark:hover', 'disabled'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^text-(${colorsToRegex})-600$`),
|
pattern: RegExp(`^text-(${colorsToRegex})-600$`),
|
||||||
variants: ["hover"],
|
variants: ['hover'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^outline-(${colorsToRegex})-400$`),
|
pattern: RegExp(`^outline-(${colorsToRegex})-400$`),
|
||||||
variants: ["dark:focus-visible"],
|
variants: ['dark:focus-visible'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^outline-(${colorsToRegex})-500$`),
|
pattern: RegExp(`^outline-(${colorsToRegex})-500$`),
|
||||||
variants: ["focus-visible"],
|
variants: ['focus-visible'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^ring-(${colorsToRegex})-300$`),
|
pattern: RegExp(`^ring-(${colorsToRegex})-300$`),
|
||||||
variants: ["focus", "dark:focus"],
|
variants: ['focus', 'dark:focus'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^ring-(${colorsToRegex})-400$`),
|
pattern: RegExp(`^ring-(${colorsToRegex})-400$`),
|
||||||
variants: ["dark:focus-visible"],
|
variants: ['dark:focus-visible'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^ring-(${colorsToRegex})-500$`),
|
pattern: RegExp(`^ring-(${colorsToRegex})-500$`),
|
||||||
variants: ["focus-visible"],
|
variants: ['focus-visible'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
message: (colorsToRegex) => [
|
message: colorsToRegex => [
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^bg-(${colorsToRegex})-50$`),
|
pattern: RegExp(`^bg-(${colorsToRegex})-50$`),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^bg-(${colorsToRegex})-900$`),
|
pattern: RegExp(`^bg-(${colorsToRegex})-900$`),
|
||||||
variants: ["dark"],
|
variants: ['dark'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^text-(${colorsToRegex})-500$`),
|
pattern: RegExp(`^text-(${colorsToRegex})-500$`),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^text-(${colorsToRegex})-300$`),
|
pattern: RegExp(`^text-(${colorsToRegex})-300$`),
|
||||||
variants: ["dark"],
|
variants: ['dark'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^border-(${colorsToRegex})-400$`),
|
pattern: RegExp(`^border-(${colorsToRegex})-400$`),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^border-(${colorsToRegex})-600$`),
|
pattern: RegExp(`^border-(${colorsToRegex})-600$`),
|
||||||
variants: ["dark"],
|
variants: ['dark'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^shadow-(${colorsToRegex})-100$`),
|
pattern: RegExp(`^shadow-(${colorsToRegex})-100$`),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: RegExp(`^shadow-(${colorsToRegex})-900$`),
|
pattern: RegExp(`^shadow-(${colorsToRegex})-900$`),
|
||||||
variants: ["dark"],
|
variants: ['dark'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
}
|
||||||
|
|
||||||
export const generateSafelist = (colors: string[], globalColors: string[]) => {
|
export const generateSafelist = (colors: string[], globalColors: string[]) => {
|
||||||
const safelist = Object.keys(safelistForComponent).flatMap(component =>
|
const safelist = Object.keys(safelistForComponent).flatMap(component =>
|
||||||
|
Loading…
Reference in New Issue
Block a user