refactor(ui): mobile enhancements to UI controls (#1916)
This commit is contained in:
@@ -99,7 +99,7 @@ export class AppAccordionComponent {
|
||||
`${neutralControlBorderClass} bg-card shadow-control`;
|
||||
protected readonly headerRowClass = 'relative flex items-stretch';
|
||||
protected readonly triggerClass =
|
||||
'relative flex h-full w-full cursor-pointer select-none items-center px-3 py-2.5 text-sm font-medium text-text-strong outline-hidden ' +
|
||||
'relative flex h-full w-full cursor-pointer select-none items-center px-3 py-2.5 text-sm font-medium text-text-strong outline-hidden pointer-coarse:min-h-12 touch-manipulation ' +
|
||||
'transition-colors hover:bg-surface-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ' +
|
||||
'aria-disabled:cursor-default aria-disabled:opacity-50';
|
||||
protected readonly labelClass = 'min-w-0 flex-1 pr-7 text-left';
|
||||
|
||||
@@ -68,7 +68,7 @@ export abstract class AppAutocompleteBaseDirective {
|
||||
protected readonly innerInputClass =
|
||||
'min-w-[6rem] flex-1 border-0 bg-transparent p-0 text-inherit outline-hidden placeholder:text-text-muted disabled:cursor-default';
|
||||
protected readonly surfaceClass = cn(overlayListSurfaceClass, connectedOverlayPanelClass, 'box-border w-full p-0');
|
||||
protected readonly listClass = cn(overlayListRootClass, 'max-h-60 overflow-y-auto p-1');
|
||||
protected readonly listClass = cn(overlayListRootClass, 'max-h-60 overflow-y-auto overscroll-contain p-1');
|
||||
protected readonly optionClass = overlayListOptionClass;
|
||||
protected readonly emptyClass = overlayListEmptyItemClass;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { cva } from 'class-variance-authority';
|
||||
import { neutralControlBorderClass } from '../control.styles';
|
||||
import { controlMinHeightBySize, neutralControlBorderClass } from '../control.styles';
|
||||
|
||||
export const autocompleteBoxVariants = cva(
|
||||
`flex w-full flex-wrap items-center gap-1.5 rounded-md border ${neutralControlBorderClass} bg-card text-text-strong shadow-control outline-hidden ` +
|
||||
@@ -8,9 +8,9 @@ export const autocompleteBoxVariants = cva(
|
||||
{
|
||||
variants: {
|
||||
size: {
|
||||
sm: 'min-h-8 px-3 py-1 text-xs',
|
||||
md: 'min-h-9 px-3 py-1 text-sm',
|
||||
lg: 'min-h-10 px-4 py-1.5 text-sm',
|
||||
sm: `${controlMinHeightBySize.sm} px-3 py-1 text-xs pointer-coarse:text-base`,
|
||||
md: `${controlMinHeightBySize.md} px-3 py-1 text-sm pointer-coarse:text-base`,
|
||||
lg: `${controlMinHeightBySize.lg} px-4 py-1.5 text-sm pointer-coarse:text-base`,
|
||||
},
|
||||
disabled: { true: 'pointer-events-none opacity-50', false: '' },
|
||||
invalid: {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { cva } from 'class-variance-authority';
|
||||
import { neutralControlBorderClass, neutralSurfaceHoverClass } from '../control.styles';
|
||||
import {
|
||||
controlHeightBySize,
|
||||
controlIconOnlyWidthBySize,
|
||||
neutralControlBorderClass,
|
||||
neutralSurfaceHoverClass,
|
||||
pressedOverlayClass,
|
||||
} from '../control.styles';
|
||||
|
||||
export type ButtonTone = 'neutral' | 'primary' | 'danger';
|
||||
export type ButtonVariant = 'soft' | 'solid' | 'ghost';
|
||||
@@ -7,8 +13,10 @@ export type ButtonSize = 'sm' | 'md' | 'lg';
|
||||
|
||||
export const buttonVariants = cva(
|
||||
'inline-flex shrink-0 cursor-pointer select-none items-center justify-center ' +
|
||||
'rounded-md border leading-none whitespace-nowrap font-medium ' +
|
||||
'transition-[background-color,border-color,color] duration-150 active:translate-y-px ' +
|
||||
'rounded-md border leading-none whitespace-nowrap font-medium touch-manipulation ' +
|
||||
'transition-[background-color,border-color,color] duration-150 ' +
|
||||
'active:translate-y-px pointer-coarse:active:translate-y-0 ' +
|
||||
pressedOverlayClass + ' ' +
|
||||
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary ' +
|
||||
'disabled:pointer-events-none disabled:opacity-50',
|
||||
{
|
||||
@@ -16,9 +24,9 @@ export const buttonVariants = cva(
|
||||
tone: { neutral: '', primary: '', danger: '' },
|
||||
variant: { soft: '', solid: '', ghost: '' },
|
||||
size: {
|
||||
sm: 'h-8 px-3 gap-1.5 text-xs',
|
||||
md: 'h-9 px-3 gap-2 text-sm',
|
||||
lg: 'h-10 px-4 gap-2 text-sm',
|
||||
sm: `${controlHeightBySize.sm} px-3 gap-1.5 text-xs`,
|
||||
md: `${controlHeightBySize.md} px-3 gap-2 text-sm`,
|
||||
lg: `${controlHeightBySize.lg} px-4 gap-2 text-sm`,
|
||||
},
|
||||
iconOnly: { true: '', false: '' },
|
||||
rounded: { true: 'rounded-full', false: '' },
|
||||
@@ -59,9 +67,9 @@ export const buttonVariants = cva(
|
||||
},
|
||||
{ tone: 'primary', variant: 'ghost', class: 'bg-transparent border-transparent text-primary hover:bg-primary/10' },
|
||||
{ tone: 'danger', variant: 'ghost', class: 'bg-transparent border-transparent text-danger hover:bg-danger/10' },
|
||||
{ iconOnly: true, size: 'sm', class: 'w-8 px-0 gap-0' },
|
||||
{ iconOnly: true, size: 'md', class: 'w-9 px-0 gap-0' },
|
||||
{ iconOnly: true, size: 'lg', class: 'w-10 px-0 gap-0' },
|
||||
{ iconOnly: true, size: 'sm', class: `${controlIconOnlyWidthBySize.sm} px-0 gap-0` },
|
||||
{ iconOnly: true, size: 'md', class: `${controlIconOnlyWidthBySize.md} px-0 gap-0` },
|
||||
{ iconOnly: true, size: 'lg', class: `${controlIconOnlyWidthBySize.lg} px-0 gap-0` },
|
||||
],
|
||||
defaultVariants: { tone: 'neutral', variant: 'soft', size: 'md', iconOnly: false, rounded: false, fluid: false },
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from '@angular/core';
|
||||
import { type FormCheckboxControl } from '@angular/forms/signals';
|
||||
import { cn } from '../cn';
|
||||
import { invisibleControlInputClass } from '../control.styles';
|
||||
import { expandedTouchTargetInputClass } from '../control.styles';
|
||||
import { APP_FIELD } from '../field/app-field.context';
|
||||
import {
|
||||
appCheckboxBoxVariants,
|
||||
@@ -87,7 +87,7 @@ export class AppCheckboxComponent implements FormCheckboxControl {
|
||||
protected readonly isUnavailable = computed(() => this.disabled() || this.readonly());
|
||||
|
||||
protected readonly rootClass = computed(() => cn(appCheckboxRootVariants({ size: this.size() }), this.styleClass()));
|
||||
protected readonly inputClass = invisibleControlInputClass;
|
||||
protected readonly inputClass = expandedTouchTargetInputClass;
|
||||
protected readonly boxClass = computed(() =>
|
||||
appCheckboxBoxVariants({ disabled: this.isUnavailable(), invalid: this.showInvalid() }),
|
||||
);
|
||||
|
||||
@@ -6,9 +6,9 @@ export type AppCheckboxSize = 'sm' | 'md' | 'lg';
|
||||
export const appCheckboxRootVariants = cva('relative inline-grid shrink-0 place-items-center align-middle', {
|
||||
variants: {
|
||||
size: {
|
||||
sm: 'size-4',
|
||||
md: 'size-5',
|
||||
lg: 'size-6',
|
||||
sm: 'size-4 pointer-coarse:size-5',
|
||||
md: 'size-5 pointer-coarse:size-6',
|
||||
lg: 'size-6 pointer-coarse:size-7',
|
||||
},
|
||||
},
|
||||
defaultVariants: { size: 'md' },
|
||||
@@ -42,9 +42,9 @@ export const appCheckboxIndicatorVariants = cva(
|
||||
{
|
||||
variants: {
|
||||
size: {
|
||||
sm: 'size-3',
|
||||
md: 'size-3.5',
|
||||
lg: 'size-4',
|
||||
sm: 'size-3 pointer-coarse:size-3.5',
|
||||
md: 'size-3.5 pointer-coarse:size-4',
|
||||
lg: 'size-4 pointer-coarse:size-5',
|
||||
},
|
||||
},
|
||||
defaultVariants: { size: 'md' },
|
||||
|
||||
@@ -5,3 +5,31 @@ export const neutralSurfaceHoverClass =
|
||||
'dark:hover:bg-[color-mix(in_srgb,var(--color-text)_9%,var(--color-card))]';
|
||||
export const invisibleControlInputClass =
|
||||
'peer absolute inset-0 z-10 m-0 size-full cursor-pointer opacity-0 disabled:cursor-not-allowed';
|
||||
|
||||
export const expandedTouchTargetInputClass =
|
||||
`${invisibleControlInputClass} pointer-coarse:left-1/2 pointer-coarse:top-1/2 ` +
|
||||
'pointer-coarse:-translate-x-1/2 pointer-coarse:-translate-y-1/2 ' +
|
||||
'pointer-coarse:h-11 pointer-coarse:w-[max(2.75rem,calc(100%+1.5rem))]';
|
||||
|
||||
export const controlHeightBySize = {
|
||||
sm: 'h-8 pointer-coarse:h-10',
|
||||
md: 'h-9 pointer-coarse:h-11',
|
||||
lg: 'h-10 pointer-coarse:h-12',
|
||||
} as const;
|
||||
export const controlMinHeightBySize = {
|
||||
sm: 'min-h-8 pointer-coarse:min-h-10',
|
||||
md: 'min-h-9 pointer-coarse:min-h-11',
|
||||
lg: 'min-h-10 pointer-coarse:min-h-12',
|
||||
} as const;
|
||||
export const controlIconOnlyWidthBySize = {
|
||||
sm: 'w-8 pointer-coarse:w-10',
|
||||
md: 'w-9 pointer-coarse:w-11',
|
||||
lg: 'w-10 pointer-coarse:w-12',
|
||||
} as const;
|
||||
|
||||
export const pressedOverlayClass =
|
||||
'relative ' +
|
||||
"after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:content-[''] " +
|
||||
'after:bg-black/10 after:opacity-0 after:transition-opacity after:duration-300 after:ease-out dark:after:bg-white/10 ' +
|
||||
'motion-reduce:after:transition-none ' +
|
||||
'pointer-coarse:active:after:opacity-100 pointer-coarse:active:after:duration-0';
|
||||
|
||||
@@ -172,7 +172,8 @@ export const DATE_PICKER_TEMPLATE = `
|
||||
<tr>
|
||||
@for (weekday of weekdays(); track weekday.key) {
|
||||
<th scope="col" class="p-0">
|
||||
<span class="flex size-9 items-center justify-center text-xs font-medium text-text-muted">
|
||||
<span
|
||||
class="flex size-9 items-center justify-center text-xs font-medium text-text-muted pointer-coarse:size-11">
|
||||
<span class="sr-only">{{ weekday.long }}</span>
|
||||
<span aria-hidden="true">{{ weekday.narrow }}</span>
|
||||
</span>
|
||||
@@ -263,7 +264,7 @@ export abstract class AppDatePickerBaseDirective {
|
||||
protected readonly popupClass = cn(overlayListSurfaceClass, connectedOverlayPanelClass, 'w-auto p-3');
|
||||
protected readonly navButtonClass =
|
||||
'flex size-7 items-center justify-center rounded-md border-0 bg-transparent text-text-muted outline-hidden ' +
|
||||
'transition-colors hover:bg-surface-hover hover:text-text-strong ' +
|
||||
'pointer-coarse:size-11 touch-manipulation transition-colors hover:bg-surface-hover hover:text-text-strong ' +
|
||||
'focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-primary';
|
||||
|
||||
protected readonly resolvedInputId = computed(() => this.inputId() || this.fieldContext?.controlId() || null);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export type AppDatePickerSize = 'sm' | 'md' | 'lg';
|
||||
|
||||
export const appDatePickerDayBase =
|
||||
'relative flex size-9 items-center justify-center rounded-md border-0 bg-transparent text-sm font-normal text-text outline-hidden ' +
|
||||
'relative flex size-9 items-center justify-center rounded-md border-0 bg-transparent text-sm font-normal text-text outline-hidden pointer-coarse:size-11 ' +
|
||||
'hover:bg-surface-hover hover:text-text-strong ' +
|
||||
'focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-primary ' +
|
||||
'disabled:pointer-events-none';
|
||||
|
||||
@@ -22,8 +22,8 @@ type AppInputType = 'text' | 'email' | 'password' | 'search' | 'tel' | 'url';
|
||||
|
||||
const ADORNMENT_CLASS = 'inline-flex shrink-0 items-center text-text-muted empty:hidden [&>svg]:size-4';
|
||||
const REVEAL_TOGGLE_CLASS =
|
||||
'inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-muted ' +
|
||||
'transition-colors hover:text-text-strong ' +
|
||||
'inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-muted -mr-1.5 pointer-coarse:size-10 pointer-coarse:-mr-3 ' +
|
||||
'touch-manipulation transition-colors hover:text-text-strong ' +
|
||||
'focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-primary ' +
|
||||
'disabled:pointer-events-none disabled:opacity-50';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { cva } from 'class-variance-authority';
|
||||
import { neutralControlBorderClass } from '../control.styles';
|
||||
import { controlHeightBySize, controlMinHeightBySize, neutralControlBorderClass } from '../control.styles';
|
||||
|
||||
export type AppInputSize = 'sm' | 'md' | 'lg';
|
||||
export type AppInputVariant = 'outlined' | 'bare';
|
||||
@@ -12,9 +12,9 @@ export const appInputVariants = cva(
|
||||
{
|
||||
variants: {
|
||||
size: {
|
||||
sm: 'text-xs',
|
||||
md: 'text-sm',
|
||||
lg: 'text-sm',
|
||||
sm: 'text-xs pointer-coarse:text-base',
|
||||
md: 'text-sm pointer-coarse:text-base',
|
||||
lg: 'text-sm pointer-coarse:text-base',
|
||||
},
|
||||
variant: {
|
||||
outlined:
|
||||
@@ -25,12 +25,12 @@ export const appInputVariants = cva(
|
||||
},
|
||||
},
|
||||
compoundVariants: [
|
||||
{ variant: 'outlined', size: 'sm', class: 'h-8 px-3 leading-8' },
|
||||
{ variant: 'outlined', size: 'md', class: 'h-9 px-3 leading-9' },
|
||||
{ variant: 'outlined', size: 'lg', class: 'h-10 px-4 leading-10' },
|
||||
{ variant: 'bare', size: 'sm', class: 'h-full min-h-8 px-3' },
|
||||
{ variant: 'bare', size: 'md', class: 'h-full min-h-9 px-4' },
|
||||
{ variant: 'bare', size: 'lg', class: 'h-full min-h-10 px-4' },
|
||||
{ variant: 'outlined', size: 'sm', class: `${controlHeightBySize.sm} px-3 leading-8` },
|
||||
{ variant: 'outlined', size: 'md', class: `${controlHeightBySize.md} px-3 leading-9` },
|
||||
{ variant: 'outlined', size: 'lg', class: `${controlHeightBySize.lg} px-4 leading-10` },
|
||||
{ variant: 'bare', size: 'sm', class: `h-full ${controlMinHeightBySize.sm} px-3` },
|
||||
{ variant: 'bare', size: 'md', class: `h-full ${controlMinHeightBySize.md} px-4` },
|
||||
{ variant: 'bare', size: 'lg', class: `h-full ${controlMinHeightBySize.lg} px-4` },
|
||||
],
|
||||
defaultVariants: { size: 'md', variant: 'outlined' },
|
||||
},
|
||||
|
||||
@@ -61,7 +61,7 @@ type SummaryLayout = 'list' | 'inline';
|
||||
} @else {
|
||||
<button
|
||||
type="button"
|
||||
class="block w-full truncate text-left font-medium text-current underline-offset-2 hover:underline focus-visible:rounded-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current"
|
||||
class="block w-full truncate text-left font-medium text-current underline-offset-2 hover:underline focus-visible:rounded-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current pointer-coarse:py-1"
|
||||
(click)="focusAdjacentSummaryIssue(1)">
|
||||
{{ activeIssueMessage() }}
|
||||
</button>
|
||||
@@ -75,7 +75,7 @@ type SummaryLayout = 'list' | 'inline';
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-sm text-left text-current underline underline-offset-2 hover:no-underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current"
|
||||
class="rounded-sm text-left text-current underline underline-offset-2 hover:no-underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current pointer-coarse:py-1"
|
||||
(click)="focusIssue(issue)">
|
||||
{{ issueLabel(issue) }}
|
||||
</button>
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import { transformedValue, type FormValueControl, type ParseResult } from '@angular/forms/signals';
|
||||
import { LucideChevronDown, LucideChevronUp } from '@lucide/angular';
|
||||
import { LucideChevronDown, LucideChevronUp, LucideMinus, LucidePlus } from '@lucide/angular';
|
||||
|
||||
import { cn } from '../cn';
|
||||
import { APP_FIELD } from '../field/app-field.context';
|
||||
@@ -20,7 +20,7 @@ import { appInputVariants, type AppInputSize } from '../input/app-input.variants
|
||||
@Component({
|
||||
selector: 'app-number-input',
|
||||
standalone: true,
|
||||
imports: [LucideChevronDown, LucideChevronUp],
|
||||
imports: [LucideChevronDown, LucideChevronUp, LucideMinus, LucidePlus],
|
||||
host: { class: 'relative block w-full' },
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
template: `
|
||||
@@ -53,24 +53,26 @@ import { appInputVariants, type AppInputSize } from '../input/app-input.variants
|
||||
}
|
||||
@if (!readonly()) {
|
||||
<span
|
||||
class="pointer-events-auto my-px mr-px flex w-8 flex-col overflow-hidden rounded-r-[0.3rem] border-l border-border">
|
||||
class="pointer-events-auto my-px mr-px flex w-8 flex-col overflow-hidden rounded-r-[0.3rem] border-l border-border pointer-coarse:w-20 pointer-coarse:flex-row-reverse">
|
||||
<button
|
||||
type="button"
|
||||
tabindex="-1"
|
||||
aria-hidden="true"
|
||||
[class]="stepButtonClass"
|
||||
[class]="stepButtonClass + ' pointer-coarse:border-l pointer-coarse:border-border'"
|
||||
[disabled]="disabled() || atMax()"
|
||||
(click)="nudge(1)">
|
||||
<svg lucideChevronUp class="size-3" aria-hidden="true"></svg>
|
||||
<svg lucideChevronUp class="size-3 pointer-coarse:hidden" aria-hidden="true"></svg>
|
||||
<svg lucidePlus class="hidden size-4 pointer-coarse:block" aria-hidden="true"></svg>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
tabindex="-1"
|
||||
aria-hidden="true"
|
||||
[class]="stepButtonClass + ' border-t border-border'"
|
||||
[class]="stepButtonClass + ' border-t border-border pointer-coarse:border-t-0'"
|
||||
[disabled]="disabled() || atMin()"
|
||||
(click)="nudge(-1)">
|
||||
<svg lucideChevronDown class="size-3" aria-hidden="true"></svg>
|
||||
<svg lucideChevronDown class="size-3 pointer-coarse:hidden" aria-hidden="true"></svg>
|
||||
<svg lucideMinus class="hidden size-4 pointer-coarse:block" aria-hidden="true"></svg>
|
||||
</button>
|
||||
</span>
|
||||
}
|
||||
@@ -127,14 +129,14 @@ export class AppNumberInputComponent implements FormValueControl<number | null>
|
||||
});
|
||||
|
||||
protected readonly stepButtonClass =
|
||||
'flex flex-1 items-center justify-center text-text-muted transition-colors ' +
|
||||
'flex flex-1 items-center justify-center text-text-muted touch-manipulation transition-colors ' +
|
||||
'hover:bg-surface-hover hover:text-text-strong ' +
|
||||
'active:bg-[color-mix(in_srgb,var(--color-text)_14%,transparent)] active:text-text-strong ' +
|
||||
'disabled:pointer-events-none disabled:opacity-40';
|
||||
|
||||
protected readonly inputPaddingClass = computed(() => {
|
||||
if (this.unit()) return 'pr-16';
|
||||
return this.readonly() ? '' : 'pr-9';
|
||||
if (this.unit()) return 'pr-16 pointer-coarse:pr-28';
|
||||
return this.readonly() ? '' : 'pr-9 pointer-coarse:pr-22';
|
||||
});
|
||||
protected readonly inputClass = computed(() =>
|
||||
cn(
|
||||
|
||||
@@ -7,7 +7,8 @@ export const overlayListRootClass = 'm-0 flex list-none flex-col p-0 outline-non
|
||||
const overlayListItemStateClass = 'hover:bg-surface-hover hover:text-text-strong';
|
||||
export const overlayListActiveItemStateClass = 'bg-surface-hover text-text-strong';
|
||||
export const overlayListItemRowClass =
|
||||
'flex h-7 w-full select-none items-center gap-2 px-2 py-0 text-sm leading-5 text-inherit no-underline outline-hidden';
|
||||
'flex min-h-7 w-full select-none items-center gap-2 px-2 py-1 text-sm leading-5 text-inherit no-underline outline-hidden ' +
|
||||
'pointer-coarse:min-h-11 pointer-coarse:px-3';
|
||||
export const overlayListItemContentClass = cn(
|
||||
'rounded-sm text-text',
|
||||
overlayListItemStateClass,
|
||||
@@ -18,7 +19,8 @@ export const overlayListOptionClass = cn(
|
||||
overlayListItemStateClass,
|
||||
'aria-disabled:pointer-events-none aria-disabled:opacity-50',
|
||||
);
|
||||
export const overlayListEmptyItemClass = 'flex h-7 items-center px-2 text-sm leading-5 text-text-muted';
|
||||
export const overlayListEmptyItemClass =
|
||||
'flex min-h-7 items-center px-2 py-1 text-sm leading-5 text-text-muted pointer-coarse:min-h-11 pointer-coarse:px-3';
|
||||
|
||||
export const overlayListSectionLabelClass =
|
||||
'flex h-5 w-full cursor-default select-none items-center px-2 py-0 text-xs font-semibold leading-5 text-inherit no-underline outline-hidden';
|
||||
|
||||
@@ -74,9 +74,9 @@ const dotBase =
|
||||
export const appRadioGroupDotVariants = cva(dotBase, {
|
||||
variants: {
|
||||
size: {
|
||||
sm: 'size-3.5 before:size-1',
|
||||
md: 'size-4 before:size-1.5',
|
||||
lg: 'size-5 before:size-2',
|
||||
sm: 'size-3.5 before:size-1 pointer-coarse:size-4 pointer-coarse:before:size-1.5',
|
||||
md: 'size-4 before:size-1.5 pointer-coarse:size-5 pointer-coarse:before:size-2',
|
||||
lg: 'size-5 before:size-2 pointer-coarse:size-6 pointer-coarse:before:size-2.5',
|
||||
},
|
||||
variant: {
|
||||
list:
|
||||
@@ -87,8 +87,9 @@ export const appRadioGroupDotVariants = cva(dotBase, {
|
||||
},
|
||||
},
|
||||
compoundVariants: [
|
||||
{ variant: 'list', size: 'sm', class: 'mt-px' },
|
||||
{ variant: 'list', size: ['md', 'lg'], class: 'mt-0.5' },
|
||||
{ variant: 'list', size: 'sm', class: 'mt-px pointer-coarse:mt-0.5' },
|
||||
{ variant: 'list', size: 'md', class: 'mt-0.5 pointer-coarse:mt-0' },
|
||||
{ variant: 'list', size: 'lg', class: 'mt-0.5 pointer-coarse:-mt-0.5' },
|
||||
],
|
||||
defaultVariants: { size: 'md', variant: 'list' },
|
||||
});
|
||||
|
||||
@@ -20,7 +20,10 @@ import { APP_FIELD } from '../field/app-field.context';
|
||||
const STAR_PATH =
|
||||
'M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006 5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434 2.082-5.005Z';
|
||||
|
||||
const STAR_SIZES: Record<'sm' | 'md' | 'lg', string> = { sm: '14px', md: '18px', lg: '22px' };
|
||||
type RatingSize = 'sm' | 'md' | 'lg';
|
||||
|
||||
const STAR_SIZES: Record<RatingSize, string> = { sm: '14px', md: '18px', lg: '22px' };
|
||||
const STAR_SIZES_COARSE: Record<RatingSize, string> = { sm: '18px', md: '22px', lg: '28px' };
|
||||
|
||||
interface Star {
|
||||
readonly value: number;
|
||||
@@ -47,7 +50,8 @@ interface Star {
|
||||
[attr.aria-invalid]="showInvalid() ? 'true' : null"
|
||||
[attr.aria-busy]="pending() ? 'true' : null"
|
||||
[class.opacity-50]="disabled()"
|
||||
[style.--star-size]="starSize()">
|
||||
[style.--star-size-fine]="starSize()"
|
||||
[style.--star-size-coarse]="starSizeCoarse()">
|
||||
@for (star of starList(); track $index) {
|
||||
<span class="star" [style.--fill]="star.fill + '%'">
|
||||
<svg class="star-base" viewBox="0 0 24 24" aria-hidden="true"><path [attr.d]="path" /></svg>
|
||||
@@ -67,9 +71,11 @@ interface Star {
|
||||
[class.expandable]="expandable()"
|
||||
[class.expanded]="isExpanded()"
|
||||
[class.opacity-50]="disabled()"
|
||||
[style.--star-size]="starSize()"
|
||||
(mouseenter)="onEnter()"
|
||||
(mouseleave)="onLeave()">
|
||||
[style.--star-size-fine]="starSize()"
|
||||
[style.--star-size-coarse]="starSizeCoarse()"
|
||||
(pointerdown)="onPointerDown($event)"
|
||||
(pointerenter)="onEnter($event)"
|
||||
(pointerleave)="onLeave($event)">
|
||||
<input
|
||||
#input
|
||||
type="range"
|
||||
@@ -88,7 +94,8 @@ interface Star {
|
||||
[attr.aria-busy]="pending() ? 'true' : null"
|
||||
[attr.aria-valuetext]="valueText()"
|
||||
(input)="onRange(input.value)"
|
||||
(change)="touched.set(true)" />
|
||||
(change)="touched.set(true)"
|
||||
(blur)="onRangeBlur()" />
|
||||
@for (star of starList(); track $index) {
|
||||
<button
|
||||
type="button"
|
||||
@@ -117,12 +124,28 @@ interface Star {
|
||||
`,
|
||||
styles: `
|
||||
.rating {
|
||||
--star-size: var(--star-size-fine);
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
line-height: 0;
|
||||
}
|
||||
@media (pointer: coarse) {
|
||||
.rating {
|
||||
--star-size: var(--star-size-coarse);
|
||||
}
|
||||
.editable .star:not(.hidden-star) {
|
||||
width: calc(var(--star-size) + 4px);
|
||||
height: calc(var(--star-size) + 18px);
|
||||
}
|
||||
.editable .star svg {
|
||||
inset: 50% auto auto 50%;
|
||||
width: var(--star-size);
|
||||
height: var(--star-size);
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
}
|
||||
.editable:has(.range:focus-visible) {
|
||||
outline: 2px solid var(--color-primary);
|
||||
outline-offset: 3px;
|
||||
@@ -198,7 +221,7 @@ export class AppRatingComponent implements FormValueControl<number> {
|
||||
readonly readonly = input(false, { transform: booleanAttribute });
|
||||
readonly expandable = input(false, { transform: booleanAttribute });
|
||||
readonly showValue = input(false, { transform: booleanAttribute });
|
||||
readonly size = input<'sm' | 'md' | 'lg'>('md');
|
||||
readonly size = input<RatingSize>('md');
|
||||
|
||||
readonly disabled = input(false, { transform: booleanAttribute });
|
||||
readonly required = input(false, { transform: booleanAttribute });
|
||||
@@ -213,10 +236,12 @@ export class AppRatingComponent implements FormValueControl<number> {
|
||||
protected readonly path = STAR_PATH;
|
||||
protected readonly formatRating = formatRating;
|
||||
protected readonly starSize = computed(() => STAR_SIZES[this.size()]);
|
||||
protected readonly starSizeCoarse = computed(() => STAR_SIZES_COARSE[this.size()]);
|
||||
protected readonly step = computed(() => (this.expandable() ? 0.5 : 1));
|
||||
|
||||
private readonly expanded = signal(false);
|
||||
private readonly hoverValue = signal<number | null>(null);
|
||||
private lastPointerType = 'mouse';
|
||||
protected readonly isExpanded = computed(() => this.expandable() && this.expanded());
|
||||
protected readonly preview = computed(() => this.hoverValue() ?? this.value());
|
||||
|
||||
@@ -275,17 +300,23 @@ export class AppRatingComponent implements FormValueControl<number> {
|
||||
const nextValue = Number(raw);
|
||||
if (!Number.isFinite(nextValue)) return;
|
||||
|
||||
if (this.expandable() && !this.disabled()) this.expanded.set(true);
|
||||
|
||||
this.value.set(Math.max(0, Math.min(this.stars(), nextValue)));
|
||||
}
|
||||
|
||||
protected onEnter(): void {
|
||||
if (this.expandable() && !this.disabled()) this.expanded.set(true);
|
||||
protected onRangeBlur(): void {
|
||||
this.touched.set(true);
|
||||
this.collapse();
|
||||
}
|
||||
|
||||
protected onLeave(): void {
|
||||
if (!this.expandable()) return;
|
||||
this.expanded.set(false);
|
||||
this.hoverValue.set(null);
|
||||
protected onEnter(event: PointerEvent): void {
|
||||
if (event.pointerType === 'mouse' && this.expandable() && !this.disabled()) this.expanded.set(true);
|
||||
}
|
||||
|
||||
protected onLeave(event: PointerEvent): void {
|
||||
if (event.pointerType !== 'mouse') return;
|
||||
this.collapse();
|
||||
}
|
||||
|
||||
protected onStarHover(value: number): void {
|
||||
@@ -294,6 +325,10 @@ export class AppRatingComponent implements FormValueControl<number> {
|
||||
this.hoverValue.set(value);
|
||||
}
|
||||
|
||||
protected onPointerDown(event: PointerEvent): void {
|
||||
this.lastPointerType = event.pointerType || 'mouse';
|
||||
}
|
||||
|
||||
protected onStarClick(value: number): void {
|
||||
if (this.disabled()) return;
|
||||
this.touched.set(true);
|
||||
@@ -303,12 +338,17 @@ export class AppRatingComponent implements FormValueControl<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
this.value.set(this.value() === value ? 0 : value);
|
||||
const nextValue = this.value() === value ? 0 : value;
|
||||
this.value.set(nextValue);
|
||||
this.hoverValue.set(nextValue > 0 ? nextValue : null);
|
||||
|
||||
if (this.expandable()) {
|
||||
this.expanded.set(false);
|
||||
this.hoverValue.set(null);
|
||||
}
|
||||
if (this.lastPointerType !== 'mouse') this.collapse();
|
||||
}
|
||||
|
||||
private collapse(): void {
|
||||
if (!this.expandable()) return;
|
||||
this.expanded.set(false);
|
||||
this.hoverValue.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,18 +72,13 @@ import { type SelectOption } from './app-select.options';
|
||||
<button
|
||||
type="button"
|
||||
[attr.aria-label]="'shared.ui.select.clearSelection' | transloco"
|
||||
class="relative z-20 flex h-full shrink-0 items-center justify-center border-0 bg-transparent p-0 text-text-muted transition-colors hover:text-text-strong"
|
||||
[class.w-9]="variant() !== 'bare'"
|
||||
[class.w-7]="variant() === 'bare'"
|
||||
[class]="clearButtonClass()"
|
||||
(click)="clear($event)">
|
||||
<svg lucideX class="size-4" aria-hidden="true"></svg>
|
||||
</button>
|
||||
}
|
||||
|
||||
<span
|
||||
class="flex h-full shrink-0 items-center justify-center text-text-muted"
|
||||
[class.w-9]="variant() !== 'bare'"
|
||||
[class.w-7]="variant() === 'bare'">
|
||||
<span [class]="indicatorClass()">
|
||||
@if (pending()) {
|
||||
<svg lucideLoaderCircle class="size-4 animate-spin" aria-hidden="true"></svg>
|
||||
} @else {
|
||||
@@ -107,7 +102,7 @@ import { type SelectOption } from './app-select.options';
|
||||
(attach)="onOverlayAttach()">
|
||||
<div [class]="surfaceClass">
|
||||
@if (filter()) {
|
||||
<div class="flex h-9 items-center border-b border-border pl-3 pr-2 text-text-muted">
|
||||
<div [class]="filterRowClass">
|
||||
<input
|
||||
#filterInput
|
||||
type="text"
|
||||
@@ -116,7 +111,7 @@ import { type SelectOption } from './app-select.options';
|
||||
(keydown)="onFilterKeydown($event)"
|
||||
[placeholder]="filterPlaceholder() || ('shared.ui.select.search' | transloco)"
|
||||
[readonly]="readonly()"
|
||||
class="h-full min-w-0 flex-1 border-0 bg-transparent px-0 pr-2 text-sm text-text-strong outline-hidden placeholder:text-text-muted focus:outline-hidden" />
|
||||
[class]="filterInputClass" />
|
||||
<svg lucideSearch class="size-4 shrink-0" aria-hidden="true"></svg>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -102,12 +102,31 @@ export abstract class AppSelectBaseDirective<T> {
|
||||
connectedOverlayPanelClass,
|
||||
'box-border flex w-full flex-col overflow-hidden p-0',
|
||||
);
|
||||
private readonly triggerZoneWidthClass = computed(() =>
|
||||
this.variant() !== 'bare' ? 'w-9 pointer-coarse:w-11' : 'w-7 pointer-coarse:w-10',
|
||||
);
|
||||
protected readonly filterRowClass =
|
||||
'flex h-9 items-center border-b border-border pl-3 pr-2 text-text-muted pointer-coarse:h-11';
|
||||
protected readonly filterInputClass =
|
||||
'h-full min-w-0 flex-1 border-0 bg-transparent px-0 pr-2 text-sm text-text-strong outline-hidden ' +
|
||||
'placeholder:text-text-muted focus:outline-hidden pointer-coarse:text-base';
|
||||
protected readonly clearButtonClass = computed(() =>
|
||||
cn(
|
||||
'relative z-20 flex h-full shrink-0 items-center justify-center border-0 bg-transparent p-0 text-text-muted',
|
||||
'touch-manipulation transition-colors hover:text-text-strong',
|
||||
this.triggerZoneWidthClass(),
|
||||
),
|
||||
);
|
||||
protected readonly indicatorClass = computed(() =>
|
||||
cn('flex h-full shrink-0 items-center justify-center text-text-muted', this.triggerZoneWidthClass()),
|
||||
);
|
||||
protected readonly overlayPositions = connectedOverlayPositions;
|
||||
protected readonly overlayScrollStrategy = connectedOverlayScrollStrategy(this.overlayService);
|
||||
protected readonly listClass = computed(() =>
|
||||
cn(
|
||||
overlayListRootClass,
|
||||
this.filter() ? 'max-h-[12.75rem] overflow-y-auto p-1' : 'max-h-60 overflow-y-auto p-1',
|
||||
'overflow-y-auto overscroll-contain p-1',
|
||||
this.filter() ? 'max-h-[12.75rem]' : 'max-h-60',
|
||||
),
|
||||
);
|
||||
protected readonly sectionClass = cn(overlayListSectionLabelClass, 'text-text-muted');
|
||||
|
||||
@@ -81,18 +81,13 @@ import { type SelectOption } from './app-select.options';
|
||||
<button
|
||||
type="button"
|
||||
[attr.aria-label]="'shared.ui.select.clearSelection' | transloco"
|
||||
class="relative z-20 flex h-full shrink-0 items-center justify-center border-0 bg-transparent p-0 text-text-muted transition-colors hover:text-text-strong"
|
||||
[class.w-9]="variant() !== 'bare'"
|
||||
[class.w-7]="variant() === 'bare'"
|
||||
[class]="clearButtonClass()"
|
||||
(click)="clear($event)">
|
||||
<svg lucideX class="size-4" aria-hidden="true"></svg>
|
||||
</button>
|
||||
}
|
||||
|
||||
<span
|
||||
class="flex h-full shrink-0 items-center justify-center text-text-muted"
|
||||
[class.w-9]="variant() !== 'bare'"
|
||||
[class.w-7]="variant() === 'bare'">
|
||||
<span [class]="indicatorClass()">
|
||||
@if (pending()) {
|
||||
<svg lucideLoaderCircle class="size-4 animate-spin" aria-hidden="true"></svg>
|
||||
} @else {
|
||||
@@ -116,7 +111,7 @@ import { type SelectOption } from './app-select.options';
|
||||
(attach)="onOverlayAttach()">
|
||||
<div [class]="surfaceClass">
|
||||
@if (filter()) {
|
||||
<div class="flex h-9 items-center border-b border-border pl-3 pr-2 text-text-muted">
|
||||
<div [class]="filterRowClass">
|
||||
<input
|
||||
#filterInput
|
||||
type="text"
|
||||
@@ -125,7 +120,7 @@ import { type SelectOption } from './app-select.options';
|
||||
(keydown)="onFilterKeydown($event)"
|
||||
[placeholder]="filterPlaceholder() || ('shared.ui.select.search' | transloco)"
|
||||
[readonly]="readonly()"
|
||||
class="h-full min-w-0 flex-1 border-0 bg-transparent px-0 pr-2 text-sm text-text-strong outline-hidden placeholder:text-text-muted focus:outline-hidden" />
|
||||
[class]="filterInputClass" />
|
||||
<svg lucideSearch class="size-4 shrink-0" aria-hidden="true"></svg>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { cva } from 'class-variance-authority';
|
||||
import { neutralControlBorderClass } from '../control.styles';
|
||||
import { controlHeightBySize, controlMinHeightBySize, neutralControlBorderClass } from '../control.styles';
|
||||
|
||||
export type AppSelectSize = 'sm' | 'md' | 'lg';
|
||||
export type AppSelectVariant = 'outlined' | 'bare';
|
||||
@@ -10,9 +10,9 @@ export const appSelectTriggerVariants = cva(
|
||||
{
|
||||
variants: {
|
||||
size: {
|
||||
sm: 'text-xs',
|
||||
md: 'text-sm',
|
||||
lg: 'text-sm',
|
||||
sm: 'text-xs pointer-coarse:text-base',
|
||||
md: 'text-sm pointer-coarse:text-base',
|
||||
lg: 'text-sm pointer-coarse:text-base',
|
||||
},
|
||||
variant: {
|
||||
outlined:
|
||||
@@ -31,12 +31,12 @@ export const appSelectTriggerVariants = cva(
|
||||
},
|
||||
},
|
||||
compoundVariants: [
|
||||
{ variant: 'outlined', size: 'sm', class: 'h-8' },
|
||||
{ variant: 'outlined', size: 'md', class: 'h-9' },
|
||||
{ variant: 'outlined', size: 'lg', class: 'h-10' },
|
||||
{ variant: 'bare', size: 'sm', class: 'h-full min-h-8' },
|
||||
{ variant: 'bare', size: 'md', class: 'h-full min-h-9' },
|
||||
{ variant: 'bare', size: 'lg', class: 'h-full min-h-10' },
|
||||
{ variant: 'outlined', size: 'sm', class: controlHeightBySize.sm },
|
||||
{ variant: 'outlined', size: 'md', class: controlHeightBySize.md },
|
||||
{ variant: 'outlined', size: 'lg', class: controlHeightBySize.lg },
|
||||
{ variant: 'bare', size: 'sm', class: `h-full ${controlMinHeightBySize.sm}` },
|
||||
{ variant: 'bare', size: 'md', class: `h-full ${controlMinHeightBySize.md}` },
|
||||
{ variant: 'bare', size: 'lg', class: `h-full ${controlMinHeightBySize.lg}` },
|
||||
],
|
||||
defaultVariants: { size: 'md', variant: 'outlined', invalid: false, disabled: false },
|
||||
},
|
||||
@@ -50,9 +50,9 @@ export const appSelectLabelVariants = cva(
|
||||
variant: { outlined: '', bare: '' },
|
||||
},
|
||||
compoundVariants: [
|
||||
{ variant: 'outlined', size: 'sm', class: 'px-3 leading-8' },
|
||||
{ variant: 'outlined', size: 'md', class: 'px-3 leading-9' },
|
||||
{ variant: 'outlined', size: 'lg', class: 'px-4 leading-10' },
|
||||
{ variant: 'outlined', size: 'sm', class: 'px-3 leading-8 pointer-coarse:leading-10' },
|
||||
{ variant: 'outlined', size: 'md', class: 'px-3 leading-9 pointer-coarse:leading-11' },
|
||||
{ variant: 'outlined', size: 'lg', class: 'px-4 leading-10 pointer-coarse:leading-12' },
|
||||
{ variant: 'bare', size: 'sm', class: 'px-3' },
|
||||
{ variant: 'bare', size: 'md', class: 'px-4' },
|
||||
{ variant: 'bare', size: 'lg', class: 'px-4' },
|
||||
|
||||
@@ -22,7 +22,7 @@ import { invisibleControlInputClass, neutralControlBorderClass } from '../contro
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
template: `
|
||||
<div
|
||||
class="relative flex h-5 w-full touch-none select-none items-center"
|
||||
class="relative flex h-5 w-full touch-pan-y select-none items-center pointer-coarse:h-11"
|
||||
[class.opacity-50]="isUnavailable()"
|
||||
[style.--pct]="fraction()">
|
||||
<input
|
||||
@@ -73,7 +73,7 @@ export class AppSliderComponent implements FormValueControl<number> {
|
||||
protected readonly inputClass = invisibleControlInputClass;
|
||||
protected readonly thumbPosition = 'calc(0.5rem + var(--pct) * (100% - 1rem))';
|
||||
protected readonly thumbClass =
|
||||
`pointer-events-none absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border ${neutralControlBorderClass} ` +
|
||||
`pointer-events-none absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border pointer-coarse:size-5 ${neutralControlBorderClass} ` +
|
||||
'bg-white shadow-control transition-shadow peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-primary';
|
||||
|
||||
private readonly fieldContext = inject(APP_FIELD, { optional: true });
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from '@angular/core';
|
||||
import { type FormCheckboxControl } from '@angular/forms/signals';
|
||||
import { cn } from '../cn';
|
||||
import { invisibleControlInputClass } from '../control.styles';
|
||||
import { expandedTouchTargetInputClass } from '../control.styles';
|
||||
import { APP_FIELD } from '../field/app-field.context';
|
||||
import {
|
||||
appSwitchRootVariants,
|
||||
@@ -76,7 +76,7 @@ export class AppSwitchComponent implements FormCheckboxControl {
|
||||
protected readonly isUnavailable = computed(() => this.disabled() || this.readonly());
|
||||
|
||||
protected readonly rootClass = computed(() => cn(appSwitchRootVariants({ size: this.size() }), this.styleClass()));
|
||||
protected readonly inputClass = invisibleControlInputClass;
|
||||
protected readonly inputClass = expandedTouchTargetInputClass;
|
||||
protected readonly trackClass = computed(() =>
|
||||
appSwitchTrackVariants({ disabled: this.isUnavailable(), invalid: this.showInvalid() }),
|
||||
);
|
||||
|
||||
@@ -6,9 +6,9 @@ export type AppSwitchSize = 'sm' | 'md' | 'lg';
|
||||
export const appSwitchRootVariants = cva('relative inline-flex shrink-0 align-middle', {
|
||||
variants: {
|
||||
size: {
|
||||
sm: 'h-4 w-8',
|
||||
md: 'h-5 w-10',
|
||||
lg: 'h-6 w-12',
|
||||
sm: 'h-4 w-8 pointer-coarse:h-5 pointer-coarse:w-10',
|
||||
md: 'h-5 w-10 pointer-coarse:h-6 pointer-coarse:w-12',
|
||||
lg: 'h-6 w-12 pointer-coarse:h-7 pointer-coarse:w-14',
|
||||
},
|
||||
},
|
||||
defaultVariants: { size: 'md' },
|
||||
@@ -40,9 +40,9 @@ export const appSwitchThumbVariants = cva(
|
||||
{
|
||||
variants: {
|
||||
size: {
|
||||
sm: 'size-3 peer-checked:translate-x-4',
|
||||
md: 'size-4 peer-checked:translate-x-5',
|
||||
lg: 'size-5 peer-checked:translate-x-6',
|
||||
sm: 'size-3 peer-checked:translate-x-4 pointer-coarse:size-4 pointer-coarse:peer-checked:translate-x-5',
|
||||
md: 'size-4 peer-checked:translate-x-5 pointer-coarse:size-5 pointer-coarse:peer-checked:translate-x-6',
|
||||
lg: 'size-5 peer-checked:translate-x-6 pointer-coarse:size-6 pointer-coarse:peer-checked:translate-x-7',
|
||||
},
|
||||
disabled: {
|
||||
true: 'opacity-50',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { cva } from 'class-variance-authority';
|
||||
import { controlHeightBySize } from '../control.styles';
|
||||
|
||||
export type TabsVariant = 'underline' | 'segmented';
|
||||
export type TabsPlacement = 'inline' | 'below';
|
||||
@@ -38,12 +39,12 @@ export const appTabVariants = cva(
|
||||
size: { sm: '', md: '', lg: '' },
|
||||
},
|
||||
compoundVariants: [
|
||||
{ variant: 'underline', size: 'sm', class: 'px-3 py-2 text-xs' },
|
||||
{ variant: 'underline', size: 'md', class: 'px-3.5 py-2.5 text-sm' },
|
||||
{ variant: 'underline', size: 'lg', class: 'px-4 py-3 text-sm' },
|
||||
{ variant: 'segmented', size: 'sm', class: 'h-8 px-3 text-xs' },
|
||||
{ variant: 'segmented', size: 'md', class: 'h-9 px-3 text-sm' },
|
||||
{ variant: 'segmented', size: 'lg', class: 'h-10 px-4 text-sm' },
|
||||
{ variant: 'underline', size: 'sm', class: 'px-3 py-2 text-xs pointer-coarse:min-h-10' },
|
||||
{ variant: 'underline', size: 'md', class: 'px-3.5 py-2.5 text-sm pointer-coarse:min-h-11' },
|
||||
{ variant: 'underline', size: 'lg', class: 'px-4 py-3 text-sm pointer-coarse:min-h-12' },
|
||||
{ variant: 'segmented', size: 'sm', class: `${controlHeightBySize.sm} px-3 text-xs` },
|
||||
{ variant: 'segmented', size: 'md', class: `${controlHeightBySize.md} px-3 text-sm` },
|
||||
{ variant: 'segmented', size: 'lg', class: `${controlHeightBySize.lg} px-4 text-sm` },
|
||||
],
|
||||
defaultVariants: { variant: 'underline', size: 'md' },
|
||||
},
|
||||
|
||||
@@ -38,7 +38,7 @@ export const tagVariants = cva(
|
||||
},
|
||||
clickable: {
|
||||
true:
|
||||
'cursor-pointer transition-[background-color,border-color] duration-150 ' +
|
||||
'cursor-pointer touch-manipulation transition-[background-color,border-color] duration-150 ' +
|
||||
'hover:border-current/40 active:translate-y-px ' +
|
||||
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary',
|
||||
false: '',
|
||||
@@ -49,7 +49,8 @@ export const tagVariants = cva(
|
||||
);
|
||||
|
||||
export const tagRemoveVariants = cva(
|
||||
'-my-0.5 inline-flex shrink-0 cursor-pointer items-center justify-center self-stretch rounded-r-full ' +
|
||||
'relative -my-0.5 inline-flex shrink-0 cursor-pointer items-center justify-center self-stretch rounded-r-full ' +
|
||||
"touch-manipulation pointer-coarse:after:absolute pointer-coarse:after:-inset-1.5 pointer-coarse:after:content-[''] " +
|
||||
'transition-colors hover:bg-current/15 ' +
|
||||
'focus-visible:outline-1 focus-visible:-outline-offset-1 focus-visible:outline-current',
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ import { appTextareaVariants } from './app-textarea.variants';
|
||||
[attr.minlength]="minLength()"
|
||||
[attr.rows]="rows()"
|
||||
[style.height]="initialHeight()"
|
||||
[style.min-height]="minHeight()"
|
||||
[style.--app-textarea-min]="minHeight()"
|
||||
[value]="value()"
|
||||
[disabled]="disabled()"
|
||||
[readonly]="readonly()"
|
||||
|
||||
@@ -3,7 +3,8 @@ import { neutralControlBorderClass } from '../control.styles';
|
||||
|
||||
export const appTextareaVariants = cva(
|
||||
`block w-full rounded-md border ${neutralControlBorderClass} bg-card text-text-strong shadow-control outline-hidden ` +
|
||||
'px-3 py-[0.4375rem] text-sm leading-5 ' +
|
||||
'px-3 py-[0.4375rem] text-sm leading-5 pointer-coarse:text-base ' +
|
||||
'min-h-(--app-textarea-min) pointer-coarse:min-h-[max(2.75rem,var(--app-textarea-min))] ' +
|
||||
'placeholder:text-text-muted transition-[background-color,border-color,color] duration-150 ' +
|
||||
'focus:border-primary/60 focus:outline-1 focus:outline-offset-0 focus:outline-primary/60 ' +
|
||||
'disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-danger aria-invalid:focus:border-danger aria-invalid:focus:outline-danger',
|
||||
|
||||
@@ -28,6 +28,7 @@ let nextId = 0;
|
||||
'(mouseenter)': 'show()',
|
||||
'(mouseleave)': 'hide()',
|
||||
'(keydown.escape)': 'hide()',
|
||||
'(pointerdown)': 'onHostPointerDown($event)',
|
||||
},
|
||||
})
|
||||
export class AppTooltipDirective {
|
||||
@@ -77,6 +78,18 @@ export class AppTooltipDirective {
|
||||
});
|
||||
}
|
||||
|
||||
protected onHostPointerDown(event: PointerEvent): void {
|
||||
if (event.pointerType === 'mouse' || this.disabled() || !this.text().trim()) return;
|
||||
this.show();
|
||||
document.addEventListener('pointerdown', this.onDocumentPointerDown, true);
|
||||
}
|
||||
|
||||
private readonly onDocumentPointerDown = (event: PointerEvent): void => {
|
||||
if (this.host.nativeElement.contains(event.target as Node)) return;
|
||||
document.removeEventListener('pointerdown', this.onDocumentPointerDown, true);
|
||||
this.hide();
|
||||
};
|
||||
|
||||
protected show(): void {
|
||||
if (this.disabled() || !this.text().trim()) return;
|
||||
this.clearHideTimer();
|
||||
@@ -139,6 +152,8 @@ export class AppTooltipDirective {
|
||||
}
|
||||
|
||||
private detach(): void {
|
||||
document.removeEventListener('pointerdown', this.onDocumentPointerDown, true);
|
||||
|
||||
if (this.containerRef) {
|
||||
this.containerRef = null;
|
||||
this.removeTooltipDescription();
|
||||
|
||||
@@ -24,6 +24,8 @@ import { AVAILABLE_LANGS, TranslocoInlineLoader } from './app/core/config/transl
|
||||
import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query-experimental';
|
||||
import { provideLucideConfig } from '@lucide/angular';
|
||||
|
||||
document.addEventListener('touchstart', () => undefined, { passive: true });
|
||||
|
||||
bootstrapApplication(AppComponent, {
|
||||
providers: [
|
||||
provideZonelessChangeDetection(),
|
||||
|
||||
Reference in New Issue
Block a user