mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
move button component to ui package
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Button } from '@/Components/ui/button';
|
import { Button } from '@/packages/ui/src';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
icon: Component;
|
icon: Component;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Switch } from '@/Components/ui/switch';
|
import { Switch } from '@/Components/ui/switch';
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from '@/Components/ui/popover';
|
import { Popover, PopoverContent, PopoverTrigger } from '@/Components/ui/popover';
|
||||||
import { Button } from '@/Components/ui/button';
|
import { Button } from '@/packages/ui/src';
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { buttonVariants } from '@/Components/ui/button';
|
import { buttonVariants } from '@/packages/ui/src';
|
||||||
import { AlertDialogAction, type AlertDialogActionProps } from 'reka-ui';
|
import { AlertDialogAction, type AlertDialogActionProps } from 'reka-ui';
|
||||||
import { computed, type HTMLAttributes } from 'vue';
|
import { computed, type HTMLAttributes } from 'vue';
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { buttonVariants } from '@/Components/ui/button';
|
import { buttonVariants } from '@/packages/ui/src';
|
||||||
import { AlertDialogCancel, type AlertDialogCancelProps } from 'reka-ui';
|
import { AlertDialogCancel, type AlertDialogCancelProps } from 'reka-ui';
|
||||||
import { computed, type HTMLAttributes } from 'vue';
|
import { computed, type HTMLAttributes } from 'vue';
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge';
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { cn } from '@/lib/utils';
|
import { cn, buttonVariants } from '@/packages/ui/src';
|
||||||
import { buttonVariants } from '@/Components/ui/button';
|
|
||||||
import { CalendarCellTrigger, type CalendarCellTriggerProps, useForwardProps } from 'reka-ui';
|
import { CalendarCellTrigger, type CalendarCellTriggerProps, useForwardProps } from 'reka-ui';
|
||||||
import { computed, type HTMLAttributes } from 'vue';
|
import { computed, type HTMLAttributes } from 'vue';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from '@/Components/ui/popover';
|
import { Popover, PopoverContent, PopoverTrigger } from '@/Components/ui/popover';
|
||||||
import { Button } from '@/Components/ui/button';
|
import { Button } from '@/packages/ui/src';
|
||||||
import { Calendar } from '@/Components/ui/calendar';
|
import { Calendar } from '@/Components/ui/calendar';
|
||||||
import { CalendarIcon, XIcon } from 'lucide-vue-next';
|
import { CalendarIcon, XIcon } from 'lucide-vue-next';
|
||||||
import { formatDate } from '@/packages/ui/src/utils/time';
|
import { formatDate } from '@/packages/ui/src/utils/time';
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { cn } from '@/lib/utils';
|
import { cn, buttonVariants } from '@solidtime/ui';
|
||||||
import { buttonVariants } from '@/Components/ui/button';
|
|
||||||
import { ChevronRight } from 'lucide-vue-next';
|
import { ChevronRight } from 'lucide-vue-next';
|
||||||
import { CalendarNext, type CalendarNextProps, useForwardProps } from 'reka-ui';
|
import { CalendarNext, type CalendarNextProps, useForwardProps } from 'reka-ui';
|
||||||
import { computed, type HTMLAttributes } from 'vue';
|
import { computed, type HTMLAttributes } from 'vue';
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { cn } from '@/lib/utils';
|
import { cn, buttonVariants } from '@/packages/ui/src';
|
||||||
import { buttonVariants } from '@/Components/ui/button';
|
|
||||||
import { ChevronLeft } from 'lucide-vue-next';
|
import { ChevronLeft } from 'lucide-vue-next';
|
||||||
import { CalendarPrev, type CalendarPrevProps, useForwardProps } from 'reka-ui';
|
import { CalendarPrev, type CalendarPrevProps, useForwardProps } from 'reka-ui';
|
||||||
import { computed, type HTMLAttributes } from 'vue';
|
import { computed, type HTMLAttributes } from 'vue';
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { cn } from '@/lib/utils';
|
import { cn, buttonVariants } from '@/packages/ui/src';
|
||||||
import { buttonVariants } from '@/Components/ui/button';
|
|
||||||
import {
|
import {
|
||||||
RangeCalendarCellTrigger,
|
RangeCalendarCellTrigger,
|
||||||
type RangeCalendarCellTriggerProps,
|
type RangeCalendarCellTriggerProps,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { cn } from '@/lib/utils';
|
import { cn, buttonVariants } from '@/packages/ui/src';
|
||||||
import { buttonVariants } from '@/Components/ui/button';
|
|
||||||
import { ChevronRight } from 'lucide-vue-next';
|
import { ChevronRight } from 'lucide-vue-next';
|
||||||
import { RangeCalendarNext, type RangeCalendarNextProps, useForwardProps } from 'reka-ui';
|
import { RangeCalendarNext, type RangeCalendarNextProps, useForwardProps } from 'reka-ui';
|
||||||
import { computed, type HTMLAttributes } from 'vue';
|
import { computed, type HTMLAttributes } from 'vue';
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { cn } from '@/lib/utils';
|
import { cn, buttonVariants } from '@/packages/ui/src';
|
||||||
import { buttonVariants } from '@/Components/ui/button';
|
|
||||||
import { ChevronLeft } from 'lucide-vue-next';
|
import { ChevronLeft } from 'lucide-vue-next';
|
||||||
import { RangeCalendarPrev, type RangeCalendarPrevProps, useForwardProps } from 'reka-ui';
|
import { RangeCalendarPrev, type RangeCalendarPrevProps, useForwardProps } from 'reka-ui';
|
||||||
import { computed, type HTMLAttributes } from 'vue';
|
import { computed, type HTMLAttributes } from 'vue';
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ import { api } from '@/packages/api/src';
|
|||||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||||
import LoadingSpinner from '@/packages/ui/src/LoadingSpinner.vue';
|
import LoadingSpinner from '@/packages/ui/src/LoadingSpinner.vue';
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge';
|
||||||
import Button from '@/Components/ui/button/Button.vue';
|
import { Button } from '@/packages/ui/src';
|
||||||
import { openFeedback } from '@/utils/feedback';
|
import { openFeedback } from '@/utils/feedback';
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
|
|||||||
1519
resources/js/packages/ui/package-lock.json
generated
1519
resources/js/packages/ui/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -60,8 +60,11 @@
|
|||||||
"@heroicons/vue": "^2.1.5",
|
"@heroicons/vue": "^2.1.5",
|
||||||
"@vueuse/core": "^12.5.0",
|
"@vueuse/core": "^12.5.0",
|
||||||
"@zodios/core": "^10.9.6",
|
"@zodios/core": "^10.9.6",
|
||||||
|
"class-variance-authority": "^0.7.1",
|
||||||
|
"clsx": "^2.1.1",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"parse-duration": "^2.0.1",
|
"parse-duration": "^2.0.1",
|
||||||
|
"reka-ui": "^2.2.0",
|
||||||
"tailwind-merge": "^2.5.2",
|
"tailwind-merge": "^2.5.2",
|
||||||
"tailwindcss": "^3.1.0",
|
"tailwindcss": "^3.1.0",
|
||||||
"vue": "^3.5.0",
|
"vue": "^3.5.0",
|
||||||
|
|||||||
25
resources/js/packages/ui/src/Buttons/Button.vue
Normal file
25
resources/js/packages/ui/src/Buttons/Button.vue
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { HTMLAttributes } from 'vue';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
import { Primitive, type PrimitiveProps } from 'reka-ui';
|
||||||
|
import { type ButtonVariants, buttonVariants } from '.';
|
||||||
|
|
||||||
|
interface Props extends PrimitiveProps {
|
||||||
|
variant?: ButtonVariants['variant'];
|
||||||
|
size?: ButtonVariants['size'];
|
||||||
|
class?: HTMLAttributes['class'];
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
as: 'button',
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Primitive
|
||||||
|
:as="as"
|
||||||
|
:as-child="asChild"
|
||||||
|
:class="cn(buttonVariants({ variant, size }), props.class)">
|
||||||
|
<slot />
|
||||||
|
</Primitive>
|
||||||
|
</template>
|
||||||
36
resources/js/packages/ui/src/Buttons/index.ts
Normal file
36
resources/js/packages/ui/src/Buttons/index.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { cva, type VariantProps } from 'class-variance-authority';
|
||||||
|
|
||||||
|
export { default as Button } from './Button.vue';
|
||||||
|
|
||||||
|
export const buttonVariants = cva(
|
||||||
|
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
||||||
|
{
|
||||||
|
variants: {
|
||||||
|
variant: {
|
||||||
|
default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90',
|
||||||
|
destructive:
|
||||||
|
'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
|
||||||
|
outline:
|
||||||
|
'border shadow-xs hover:text-text-primary bg-card-background dark:bg-transparent border-input dark:border-input hover:bg-white/5',
|
||||||
|
secondary: 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
|
||||||
|
ghost: 'hover:bg-white/5',
|
||||||
|
link: 'text-primary underline-offset-4 hover:underline',
|
||||||
|
input: 'border-input-border border bg-input-background text-text-primary focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-transparent shadow-sm',
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
default: 'h-9 px-4 py-2',
|
||||||
|
xs: 'h-7 rounded px-2',
|
||||||
|
sm: 'h-8 rounded-md px-3 text-xs',
|
||||||
|
lg: 'h-10 rounded-md px-8',
|
||||||
|
icon: 'h-9 w-9',
|
||||||
|
input: 'h-[42px] px-3 py-2 text-base',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
variant: 'default',
|
||||||
|
size: 'default',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
export type ButtonVariants = VariantProps<typeof buttonVariants>;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from '@/Components/ui/popover';
|
import { Popover, PopoverContent, PopoverTrigger } from '@/Components/ui/popover';
|
||||||
import { Button } from '@/Components/ui/button';
|
import Button from '../Buttons/Button.vue';
|
||||||
import { RangeCalendar } from '@/Components/ui/range-calendar';
|
import { RangeCalendar } from '@/Components/ui/range-calendar';
|
||||||
import { CalendarDate } from '@internationalized/date';
|
import { CalendarDate } from '@internationalized/date';
|
||||||
import { CalendarIcon } from 'lucide-vue-next';
|
import { CalendarIcon } from 'lucide-vue-next';
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import DatePicker from '@/packages/ui/src/Input/DatePicker.vue';
|
|||||||
import { getDayJsInstance, getLocalizedDayJs } from '@/packages/ui/src/utils/time';
|
import { getDayJsInstance, getLocalizedDayJs } from '@/packages/ui/src/utils/time';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import TimePickerSimple from '@/packages/ui/src/Input/TimePickerSimple.vue';
|
import TimePickerSimple from '@/packages/ui/src/Input/TimePickerSimple.vue';
|
||||||
import { Button } from '@/Components/ui/button';
|
import Button from '../Buttons/Button.vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
start: string;
|
start: string;
|
||||||
|
|||||||
@@ -10,8 +10,12 @@ import * as color from './utils/color';
|
|||||||
import * as random from './utils/random';
|
import * as random from './utils/random';
|
||||||
import * as time from './utils/time';
|
import * as time from './utils/time';
|
||||||
|
|
||||||
|
export { cn } from './utils/cn';
|
||||||
|
export { buttonVariants, type ButtonVariants } from './Buttons/index';
|
||||||
|
|
||||||
import PrimaryButton from './Buttons/PrimaryButton.vue';
|
import PrimaryButton from './Buttons/PrimaryButton.vue';
|
||||||
import SecondaryButton from './Buttons/SecondaryButton.vue';
|
import SecondaryButton from './Buttons/SecondaryButton.vue';
|
||||||
|
import Button from './Buttons/Button.vue';
|
||||||
import TimeTrackerStartStop from './TimeTrackerStartStop.vue';
|
import TimeTrackerStartStop from './TimeTrackerStartStop.vue';
|
||||||
import ProjectBadge from './Project/ProjectBadge.vue';
|
import ProjectBadge from './Project/ProjectBadge.vue';
|
||||||
import LoadingSpinner from './LoadingSpinner.vue';
|
import LoadingSpinner from './LoadingSpinner.vue';
|
||||||
@@ -39,6 +43,7 @@ export {
|
|||||||
color,
|
color,
|
||||||
random,
|
random,
|
||||||
time,
|
time,
|
||||||
|
Button,
|
||||||
PrimaryButton,
|
PrimaryButton,
|
||||||
SecondaryButton,
|
SecondaryButton,
|
||||||
TimeTrackerStartStop,
|
TimeTrackerStartStop,
|
||||||
|
|||||||
6
resources/js/packages/ui/src/utils/cn.ts
Normal file
6
resources/js/packages/ui/src/utils/cn.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { type ClassValue, clsx } from 'clsx';
|
||||||
|
import { twMerge } from 'tailwind-merge';
|
||||||
|
|
||||||
|
export function cn(...inputs: ClassValue[]) {
|
||||||
|
return twMerge(clsx(inputs.filter(Boolean)));
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./resources/js/*"],
|
"@/*": ["./resources/js/*"],
|
||||||
|
"@solidtime/ui": ["./resources/js/packages/ui/src/index.ts"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user