Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions apps/web/public/components/button/doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

[z-button] Directive

| Property | Description | Type | Default |
| ----------- | --------------------- | ----------------------------------------------------------------- | --------- |
| `zDisabled` | button disabled state | `boolean` | `false` |
| `zFull` | button width 100% | `boolean` | `false` |
| `zLoading` | button loading state | `boolean` | `false` |
| `zShape` | button shape | `default \| circle \| square` | `default` |
| `zSize` | button size | `default \| sm \| lg` | `default` |
| `zType` | button type | `default \| destructive \| outline \| secondary \| ghost \| link` | `default` |
| Property | Description | Type | Default |
| ----------- | --------------------- | -------------------------------------------------------------------- | --------- |
| `zDisabled` | button disabled state | `boolean` | `false` |
| `zFull` | button width 100% | `boolean` | `false` |
| `zLoading` | button loading state | `boolean` | `false` |
| `zShape` | button shape | `default \| circle \| square` | `default` |
| `zSize` | button size | `default \| xs \| sm \| lg \| icon \| icon-xs \| icon-sm \| icon-lg` | `default` |
| `zType` | button type | `default \| destructive \| outline \| secondary \| ghost \| link` | `default` |
35 changes: 22 additions & 13 deletions apps/web/public/installation/manual/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,27 +145,36 @@ import { mergeClasses } from '@/shared/utils/merge-classes';

export const buttonVariants = cva(
mergeClasses(
'cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all active:scale-97',
"[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0",
'outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',
'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
'focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40',
'aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-lg border border-transparent bg-clip-padding',
"text-sm font-medium focus-visible:ring-3 aria-invalid:ring-3 [&_svg:not([class*='size-'])]:size-4 inline-flex items-center",
'justify-center whitespace-nowrap transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none',
'shrink-0 [&_svg]:shrink-0 outline-none group/button select-none',
),
{
variants: {
zType: {
default: 'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
default: 'bg-primary text-primary-foreground hover:bg-primary/80',
destructive:
'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
'bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30',
outline:
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
secondary: 'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
'border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground',
secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground',
ghost:
'hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground',
link: 'text-primary underline-offset-4 hover:underline',
},
zSize: {
default: 'h-9 px-4 py-2 data-icon-only:size-9 data-icon-only:p-0',
sm: 'h-8 rounded-md gap-1.5 px-3 data-icon-only:size-8 data-icon-only:p-0',
lg: 'h-10 rounded-md px-6 data-icon-only:size-10 data-icon-only:p-0',
default: 'h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
lg: 'h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3',
icon: 'size-8',
'icon-xs':
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
'icon-sm': 'size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg',
'icon-lg': 'size-9',
},
zShape: {
default: 'rounded-md',
Expand All @@ -176,7 +185,7 @@ export const buttonVariants = cva(
true: 'w-full',
},
zLoading: {
true: 'opacity-50 pointer-events-none',
true: 'pointer-events-none opacity-50',
},
zDisabled: {
true: 'pointer-events-none opacity-50',
Expand Down
50 changes: 30 additions & 20 deletions apps/web/public/installation/manual/date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,35 @@ import { NG_VALUE_ACCESSOR, type ControlValueAccessor } from '@angular/forms';

import type { ClassValue } from 'clsx';

import { ZardButtonComponent } from '../button/button.component';
import type { ZardButtonSizeVariants, ZardButtonTypeVariants } from '../button/button.variants';
import { ZardCalendarComponent } from '../calendar/calendar.component';
import { ZardIconComponent } from '../icon/icon.component';
import { ZardPopoverComponent, ZardPopoverDirective } from '../popover/popover.component';

import { mergeClasses } from '@/shared/utils/merge-classes';

const HEIGHT_BY_SIZE: Record<NonNullable<ZardButtonSizeVariants>, string> = {
import { ZardButtonComponent, type ZardButtonTypeVariants } from '@/shared/components/button';
import { ZardCalendarComponent } from '@/shared/components/calendar';
import type { ZardDatePickerSizeVariants } from '@/shared/components/date-picker/date-picker.variants';
import { ZardIconComponent } from '@/shared/components/icon';
import { ZardPopoverComponent, ZardPopoverDirective } from '@/shared/components/popover';
import { mergeClasses, noopFn } from '@/shared/utils/merge-classes';

/**
* Height overrides for date-picker sizes.
*
* These heights intentionally differ from button size variants to accommodate
* the date-picker UI:
* - default: h-9 (vs button h-8)
* - lg: h-11 (vs button h-9)
*
* The `mergeClasses` utility (tailwind-merge) resolves class conflicts,
* allowing these values to override the base button heights defined in
* `ZardDatePickerSizeVariants`.
*/
const HEIGHT_BY_SIZE: Record<ZardDatePickerSizeVariants, string> = {
xs: 'h-7',
sm: 'h-8',
default: 'h-10',
lg: 'h-12',
default: 'h-9',
lg: 'h-11',
};

@Component({
selector: 'z-date-picker, [z-date-picker]',
imports: [ZardButtonComponent, ZardCalendarComponent, ZardPopoverComponent, ZardPopoverDirective, ZardIconComponent],
standalone: true,
template: `
<button
z-button
Expand Down Expand Up @@ -98,7 +109,7 @@ export class ZardDatePickerComponent implements ControlValueAccessor {

readonly class = input<ClassValue>('');
readonly zType = input<ZardButtonTypeVariants>('outline');
readonly zSize = input<ZardButtonSizeVariants>('default');
readonly zSize = input<ZardDatePickerSizeVariants>('default');
readonly value = model<Date | null>(null);
readonly placeholder = input<string>('Pick a date');
readonly zFormat = input<string>('MMMM d, yyyy');
Expand All @@ -108,10 +119,8 @@ export class ZardDatePickerComponent implements ControlValueAccessor {

readonly dateChange = output<Date | null>();

// eslint-disable-next-line @typescript-eslint/no-empty-function
private onChange: (value: Date | null) => void = () => {};
// eslint-disable-next-line @typescript-eslint/no-empty-function
private onTouched: () => void = () => {};
private onChange: (value: Date | null) => void = noopFn;
private onTouched: () => void = noopFn;

protected readonly buttonClasses = computed(() => {
const hasValue = !!this.value();
Expand Down Expand Up @@ -187,11 +196,12 @@ export class ZardDatePickerComponent implements ControlValueAccessor {


```angular-ts title="date-picker.variants.ts" expandable="true" expandableTitle="Expand" copyButton showLineNumbers
import { cva } from 'class-variance-authority';
import { cva, type VariantProps } from 'class-variance-authority';

const datePickerVariants = cva('', {
export const datePickerVariants = cva('', {
variants: {
zSize: {
xs: '',
sm: '',
default: '',
lg: '',
Expand All @@ -208,7 +218,7 @@ const datePickerVariants = cva('', {
},
});

export { datePickerVariants };
export type ZardDatePickerSizeVariants = NonNullable<VariantProps<typeof datePickerVariants>['zSize']>;

```

Expand Down
2 changes: 1 addition & 1 deletion apps/web/public/r/button.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
{
"name": "button.variants.ts",
"content": "import { cva, type VariantProps } from 'class-variance-authority';\n\nimport { mergeClasses } from '@/shared/utils/merge-classes';\n\nexport const buttonVariants = cva(\n mergeClasses(\n 'cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all active:scale-97',\n \"[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0\",\n 'outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',\n 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',\n ),\n {\n variants: {\n zType: {\n default: 'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',\n destructive:\n 'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',\n outline:\n 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',\n secondary: 'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',\n ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n zSize: {\n default: 'h-9 px-4 py-2 data-icon-only:size-9 data-icon-only:p-0',\n sm: 'h-8 rounded-md gap-1.5 px-3 data-icon-only:size-8 data-icon-only:p-0',\n lg: 'h-10 rounded-md px-6 data-icon-only:size-10 data-icon-only:p-0',\n },\n zShape: {\n default: 'rounded-md',\n circle: 'rounded-full',\n square: 'rounded-none',\n },\n zFull: {\n true: 'w-full',\n },\n zLoading: {\n true: 'opacity-50 pointer-events-none',\n },\n zDisabled: {\n true: 'pointer-events-none opacity-50',\n },\n },\n defaultVariants: {\n zType: 'default',\n zSize: 'default',\n zShape: 'default',\n },\n },\n);\nexport type ZardButtonShapeVariants = NonNullable<VariantProps<typeof buttonVariants>['zShape']>;\nexport type ZardButtonSizeVariants = NonNullable<VariantProps<typeof buttonVariants>['zSize']>;\nexport type ZardButtonTypeVariants = NonNullable<VariantProps<typeof buttonVariants>['zType']>;\n"
"content": "import { cva, type VariantProps } from 'class-variance-authority';\n\nimport { mergeClasses } from '@/shared/utils/merge-classes';\n\nexport const buttonVariants = cva(\n mergeClasses(\n 'focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40',\n 'aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-lg border border-transparent bg-clip-padding',\n \"text-sm font-medium focus-visible:ring-3 aria-invalid:ring-3 [&_svg:not([class*='size-'])]:size-4 inline-flex items-center\",\n 'justify-center whitespace-nowrap transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none',\n 'shrink-0 [&_svg]:shrink-0 outline-none group/button select-none',\n ),\n {\n variants: {\n zType: {\n default: 'bg-primary text-primary-foreground hover:bg-primary/80',\n destructive:\n 'bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30',\n outline:\n 'border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground',\n secondary:\n 'bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground',\n ghost:\n 'hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n zSize: {\n default: 'h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',\n xs: \"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3\",\n sm: \"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5\",\n lg: 'h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3',\n icon: 'size-8',\n 'icon-xs':\n \"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3\",\n 'icon-sm': 'size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg',\n 'icon-lg': 'size-9',\n },\n zShape: {\n default: 'rounded-md',\n circle: 'rounded-full',\n square: 'rounded-none',\n },\n zFull: {\n true: 'w-full',\n },\n zLoading: {\n true: 'pointer-events-none opacity-50',\n },\n zDisabled: {\n true: 'pointer-events-none opacity-50',\n },\n },\n defaultVariants: {\n zType: 'default',\n zSize: 'default',\n zShape: 'default',\n },\n },\n);\nexport type ZardButtonShapeVariants = NonNullable<VariantProps<typeof buttonVariants>['zShape']>;\nexport type ZardButtonSizeVariants = NonNullable<VariantProps<typeof buttonVariants>['zSize']>;\nexport type ZardButtonTypeVariants = NonNullable<VariantProps<typeof buttonVariants>['zType']>;\n"
},
{
"name": "index.ts",
Expand Down
Loading