feat: v3 of UI components (#19136)

* ui playground

* add types to ui

* push avatar ignore ts and eslint errors

* feat: V3 UI avatar  (#18997)

* avatar playground

* add overflow-hidden back for loading indicator

* update lock

* feat: v3/badge  (#18999)

* badge intro

* fix text on small badge

* add dark mode warning

* feat: v3/button (#19014)

* TOC

* wip buttons

* shadows

* secondary

* semantic colours

* minimal buttons

* update disabled states

* checkbox

* dropdown v3

* load icons

* fix design sections

* fix icon gap

* fix

* remove client component from rsc

* use peer as avatar

* gif

* fix button gap - dropdown iocn

* support start icon in dropdowns

* add alert demo + v3 component + darken semantic text

* base inputs and text field

* wip input

* input field addon/suffix

* toast page

* wip select

* match designs for input and select rounded

* fix

* fix select isloading transform

* fix multi icons transition rotation

* fix group heading

* range slider demo + range slider

* range slider popover design

* v3 dialog

* fix slider thumb size

* wrap in suspense for useSearchParam difference in next14+

* base of tabs + horizontal tabs

* fix select sizing to match input 36px

* fix dark mode hover on button

* target domState class for light/dark so we work on portal elements

* fix default bg on popover

* lightmode toasts + eleveation token

* empty screen

* intro to split button concept

* mass colour updates

* intro to themes

* remove i18n from label with name

* bouncy buttons

* feat: small select

* nav item dumb component

* full demo

* settings demo

* fix tabs

* fix mt

* fix dropdown feedback from loom

* alert fixes mentioned in loom

* push font-cal

* move to fumadocs

* fix avatar

* colors table

* add typeography

* icon + spacing guide

* add border radius and shadow tables

* fix colours and border radius

* remove prose undline via fumas fork

* fix icon buttons sizes

* button group component

* fix horizontal tabs

* tab fixes

* switches

* pagination component

* show toasts components raw

* sync with airtable

* add use client

* 10px on input again

* 10px in select also

* fix input height

* fix files merge

* fix loading state for icon buttons

* fix button fab

* Enable addon to now overflow to next line in DS

* use cal font for dialog text

* add avatar square variant

* fix select padding and menu size

* fix type errors

* fix type errors

* add switch small size and fix type errors

* fix ref types on input

* update web styles

* remove addonFilled to fix type errors

* push dialog fixes

* fix checkbox display

* remove prose from alert examples

* remove prose from all our component examples

* badge rounded-lg on lg size

* update colors

* force w/h on icon buttons instead of inheriting

* remove border-focus

* remove border-focus from tailwind config

* update tokens to match new colours

* add new border subtle tokens and add to toasts

* fix lg button padding

* fix and drastically improve rtl rests

* multi select use badges

* use badge design for select pills

* fix avatar alignment

* fix tests and remove redudant ones

* fix tests and remove redudant ones

* update atoms globals css

* extract tokens.css

* extract app.css

* force flex for atoms

* add @calcom/ui/css

* revert ui playground styles abstraction

* fix input focus states

* fix focus states for buttons

* feat: v3/app work (#19233)

* globals.css for app + event types listing search

* few app wide NITS

* fix select foucs within styling

* fix formbuilder switch styles

* fix disabled state of nested inputs

* workflow fixes

* webhook form fixes

* i18n on tabs info

* booking filters + tab

* fix filters spacing

* make first item so we get correct border radius if not default

* round radio group in create event types + make button small

* profile page

* update editor br

* button nits in existing places in the app

* fix timezone select and multilist in guest form

* fix text area on public booking page

* size small event types create

* margin on routing filter

* filters improvments

* routing insights fixes

* fix date filter range

* ooo fixes

* fix teams/members bulk actions

* create team UI

* i18n in useTabs instead of in tab component now

* Add event type setup border to availability

* fix bulk actions on org members table

* onboarding fixes

* fix input types with ref stripe comparision

* i18n fixes for platform

* update globals of atoms

* fix form builder firstname/lastname switch + correct footer useage

* fix select

* Revert "add @calcom/ui/css"

This reverts commit 0dd8f9012907a278cfede4a98f289cb0744c9244.

* revert tokens css

* Revert "extract app.css"

This reverts commit 10b998604816ad3310c24b36a02a638dabc5be24.

* linear nits

* workflow dropdown

* fix page theme heading sizes to match cards

* fix stepper for team creation

* adjust margin to FilterSearchField

* fix ooo icon

* fix booker and dark mode due to darkgray 50

* more dark mode fixes

* add size prop

---------

Co-authored-by: Eunjae Lee <[email protected]>
Co-authored-by: Morgan Vernay <[email protected]>

* remove ui-playground

* fix grow missing from merge

* add search icon data-test-id back to search

* fix FormAction style

* fix datatestid for apps and tabs

* change selector for team invitation e2e

* fix use data-testid from item instaed of using names

* rename upper case O

* fix unit tests data-testid

* fix unit tests data-testid

* more data-testid changes

* add data-testid to apps tab

* data-testid to installed appPage

* fix embed tests

* fix filter-popover-trigger

* use text-error and use dataId for locator

* more e2e improvment

* pass in single testId as button is now duplicate

* show field-error instead

* add test to eventtype tabs

* Add css vars to embed too\

* add scrollbar and change dialog overlay colour

* fix type

* use attribute instead of class for tab detection

* await promise

* use new tokens for sprite generation

* add correct testing Ids to e2e instead of button:text

* use testIds for creation of orgs

* Webhook receiver wait for 10 seconds

---------

Co-authored-by: Eunjae Lee <[email protected]>
Co-authored-by: Morgan Vernay <[email protected]>
Co-authored-by: Hariom <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-02-14 16:31:21 -05:00
1 parent 0f67faeef3
commit 5d709cf63c
145 files changed
+17438 -10708

No files matched your search

@@ -12,6 +12,7 @@ type AppCategoryEntry = {
name: AppCategories;
href: string;
icon: IconName;
"data-testid": string;
};
const getAppCategories = (baseURL: string, useQueryParam: boolean): AppCategoryEntry[] => {
@@ -22,41 +23,49 @@ const getAppCategories = (baseURL: string, useQueryParam: boolean): AppCategoryE
name: "analytics",
href: getHref(baseURL, "analytics", useQueryParam),
icon: "chart-bar",
"data-testid": "analytics",
},
{
name: "automation",
href: getHref(baseURL, "automation", useQueryParam),
icon: "share-2",
"data-testid": "automation",
},
{
name: "calendar",
href: getHref(baseURL, "calendar", useQueryParam),
icon: "calendar",
"data-testid": "calendar",
},
{
name: "conferencing",
href: getHref(baseURL, "conferencing", useQueryParam),
icon: "video",
"data-testid": "conferencing",
},
{
name: "crm",
href: getHref(baseURL, "crm", useQueryParam),
icon: "contact",
"data-testid": "crm",
},
{
name: "messaging",
href: getHref(baseURL, "messaging", useQueryParam),
icon: "mail",
"data-testid": "messaging",
},
{
name: "payment",
href: getHref(baseURL, "payment", useQueryParam),
icon: "credit-card",
"data-testid": "payment",
},
{
name: "other",
href: getHref(baseURL, "other", useQueryParam),
icon: "grid-3x3",
"data-testid": "other",
},
];
};
@@ -10,17 +10,15 @@ import type { InputFieldProps } from "@calcom/ui/components/form/inputs/types";
type AddonProps = {
children: React.ReactNode;
isFilled?: boolean;
className?: string;
error?: boolean;
onClickAddon?: () => void;
};
const Addon = ({ isFilled, children, className, error }: AddonProps) => (
const Addon = ({ children, className, error }: AddonProps) => (
<div
className={classNames(
"addon-wrapper border-default [input:hover_+_&]:border-emphasis [input:hover_+_&]:border-l-default [&:has(+_input:hover)]:border-emphasis [&:has(+_input:hover)]:border-r-default h-9 border px-3 transition disabled:hover:cursor-not-allowed",
isFilled && "bg-subtle",
className
)}>
<div
@@ -63,7 +61,6 @@ export const KeyField = forwardRef<HTMLInputElement, InputFieldProps & { default
placeholder = isLocaleReady && i18n.exists(`${name}_placeholder`) ? t(`${name}_placeholder`) : "",
className,
addOnLeading,
addOnFilled = true,
addOnClassname,
inputIsFullWidth,
labelSrOnly,
@@ -128,9 +125,7 @@ export const KeyField = forwardRef<HTMLInputElement, InputFieldProps & { default
dir="ltr"
className="focus-within:ring-brand-default group relative mb-1 flex items-center rounded-md transition focus-within:outline-none focus-within:ring-2">
{addOnLeading && (
<Addon
isFilled={addOnFilled}
className={classNames("ltr:rounded-l-md rtl:rounded-r-md", addOnClassname)}>
<Addon className={classNames("ltr:rounded-l-md rtl:rounded-r-md", addOnClassname)}>
{addOnLeading}
</Addon>
)}
@@ -525,7 +525,7 @@ export const FormAction = forwardRef(function FormAction<T extends typeof Button
);
}
return (
<DropdownMenuItem>
<DropdownMenuItem className="hover:bg-[initial]">
<Component
ref={forwardedRef}
{...actionProps}
@@ -178,7 +178,7 @@ export default function RoutingForms({
newFormDialogState={newFormDialogState}
setNewFormDialogState={setNewFormDialogState}>
<div className="mb-10 w-full">
<div className="flex">
<div className="mb-2 flex">
<TeamsFilter />
</div>
<FilterResults
@@ -198,7 +198,7 @@ function RoutingForm({ form, profile, ...restProps }: Props) {
) : (
<div className="mx-auto my-0 max-w-3xl md:my-24">
<div className="w-full max-w-4xl ltr:mr-2 rtl:ml-2">
<div className="main dark:bg-darkgray-100 sm:border-subtle bg-default -mx-4 rounded-md border border-neutral-200 p-4 py-6 sm:mx-0 sm:px-8">
<div className="main sm:border-subtle bg-default -mx-4 rounded-md border border-neutral-200 p-4 py-6 sm:mx-0 sm:px-8">
<div className="text-emphasis">{customPageMessage}</div>
</div>
</div>
+201 -48
View File
@@ -1,5 +1,6 @@
const plugin = require("tailwindcss/plugin");
const { fontFamily } = require("tailwindcss/defaultTheme");
const colors = require("tailwindcss/colors");
/** @type {import('tailwindcss').Config} */
const subtleColor = "#E5E7EB";
@@ -16,72 +17,191 @@ module.exports = {
],
darkMode: "class",
theme: {
spacing: {
0: "var(--cal-spacing-0)",
px: "var(--cal-spacing-px)",
0.5: "var(--cal-spacing-0_5)",
1: "var(--cal-spacing-1)",
1.5: "var(--cal-spacing-1_5)",
2: "var(--cal-spacing-2)",
2.5: "var(--cal-spacing-2_5)",
3: "var(--cal-spacing-3)",
3.5: "var(--cal-spacing-3_5)",
4: "var(--cal-spacing-4)",
5: "var(--cal-spacing-5)",
6: "var(--cal-spacing-6)",
7: "var(--cal-spacing-7)",
8: "var(--cal-spacing-8)",
9: "var(--cal-spacing-9)",
10: "var(--cal-spacing-10)",
11: "var(--cal-spacing-11)",
12: "var(--cal-spacing-12)",
14: "var(--cal-spacing-14)",
16: "var(--cal-spacing-16)",
20: "var(--cal-spacing-20)",
24: "var(--cal-spacing-24)",
28: "var(--cal-spacing-28)",
32: "var(--cal-spacing-32)",
36: "var(--cal-spacing-36)",
40: "var(--cal-spacing-40)",
44: "var(--cal-spacing-44)",
48: "var(--cal-spacing-48)",
52: "var(--cal-spacing-52)",
56: "var(--cal-spacing-56)",
60: "var(--cal-spacing-60)",
64: "var(--cal-spacing-64)",
72: "var(--cal-spacing-72)",
80: "var(--cal-spacing-80)",
96: "var(--cal-spacing-96)",
},
borderRadius: {
none: "var(--cal-radius-none)",
sm: "var(--cal-radius-sm)",
DEFAULT: "var(--cal-radius)",
md: "var(--cal-radius-md)",
lg: "var(--cal-radius-lg)",
xl: "var(--cal-radius-xl)",
"2xl": "var(--cal-radius-2xl)",
"3xl": "var(--cal-radius-3xl)",
full: "var(--cal-radius-full)",
},
extend: {
colors: {
// Standard Background
emphasis: "var(--cal-bg-emphasis)",
default: "var(--cal-bg, white)",
subtle: "var(--cal-bg-subtle)",
muted: "var(--cal-bg-muted)",
inverted: "var(--cal-bg-inverted)",
info: "var(--cal-bg-info)",
success: "var(--cal-bg-success)",
attention: "var(--cal-bg-attention)",
error: "var(--cal-bg-error)",
darkerror: "var(--cal-bg-dark-error)",
black: "#111111",
// Primary Background
primary: {
default: "var(--cal-bg-primary)",
emphasis: "var(--cal-bg-primary-emphasis)",
muted: "var(--cal-bg-primary-muted)",
},
// Brand
brand: {
default: "var(--cal-brand,#111827)",
emphasis: "var(--cal-brand-emphasis,#101010)",
subtle: "var(--cal-brand-subtle,#9CA3AF)",
accent: "var(--cal-brand-accent,white)",
},
gray: {
50: "#F9FAFB",
100: "#F3F4F6",
200: "#E5E7EB",
300: "#D1D5DB",
400: "#9CA3AF",
500: "#6B7280",
600: "#4B5563",
700: "#374151",
800: "#1F2937",
900: "#111827",
// Semantic Background
semantic: {
info: {
subtle: "var(--cal-bg-semantic-info-subtle)",
emphasis: "var(--cal-bg-semantic-info-emphasis)",
},
success: {
subtle: "var(--cal-bg-semantic-success-subtle)",
emphasis: "var(--cal-bg-semantic-success-emphasis)",
},
attention: {
subtle: "var(--cal-bg-semantic-attention-subtle)",
emphasis: "var(--cal-bg-semantic-attention-emphasis)",
},
error: {
subtle: "var(--cal-bg-semantic-error-subtle)",
emphasis: "var(--cal-bg-semantic-error-emphasis)",
},
},
darkgray: {
50: "#101010",
100: "#1c1c1c",
200: "#2b2b2b",
300: "#444444",
400: "#575757",
500: "#767676",
600: "#a5a5a5",
700: "#d6d6d6",
800: "#e8e8e8",
900: "#f3f4f6",
// Visualization Background
visualization: {
1: {
subtle: "var(--cal-bg-visualization-1-subtle)",
emphasis: "var(--cal-bg-visualization-1-emphasis)",
},
2: {
subtle: "var(--cal-bg-visualization-2-subtle)",
emphasis: "var(--cal-bg-visualization-2-emphasis)",
},
3: {
subtle: "var(--cal-bg-visualization-3-subtle)",
emphasis: "var(--cal-bg-visualization-3-emphasis)",
},
4: {
subtle: "var(--cal-bg-visualization-4-subtle)",
emphasis: "var(--cal-bg-visualization-4-emphasis)",
},
5: {
subtle: "var(--cal-bg-visualization-5-subtle)",
emphasis: "var(--cal-bg-visualization-5-emphasis)",
},
6: {
subtle: "var(--cal-bg-visualization-6-subtle)",
emphasis: "var(--cal-bg-visualization-6-emphasis)",
},
7: {
subtle: "var(--cal-bg-visualization-7-subtle)",
emphasis: "var(--cal-bg-visualization-7-emphasis)",
},
},
// Legacy - Consider deprecating
info: "var(--cal-bg-info)",
success: "var(--cal-bg-success)",
attention: "var(--cal-bg-attention)",
error: "var(--cal-bg-error)",
darkerror: "var(--cal-bg-dark-error)",
// Base colors
black: "#111111",
gray: colors.gray,
darkgray: colors.slate,
},
borderColor: {
emphasis: "var(--cal-border-emphasis, #9CA3AF)",
default: "var(--cal-border, #D1D5DB)",
subtle: `var(--cal-border-subtle, ${subtleColor})`,
muted: "var(--cal-border-muted, #F3F4F6)",
// Standard Borders
emphasis: "var(--cal-border-emphasis)",
default: "var(--cal-border)",
subtle: "var(--cal-border-subtle)",
muted: "var(--cal-border-muted)",
// Semantic Borders
semantic: {
error: "var(--cal-border-semantic-error)",
"attention-subtle": "var(--cal-border-semantic-attention-subtle)",
"error-subtle": "var(--cal-border-semantic-error-subtle)",
},
// Used in booker embed customization
booker: `var(--cal-border-booker, ${subtleColor})`,
error: "var(--cal-border-error, #AA2E26)",
focus: "var(--cal-border-focus, #1A1A1A)",
"cal-bg": "var(--cal-bg, white)",
// Legacy - Consider deprecating
error: "var(--cal-border-error)",
"cal-bg": "var(--cal-bg)",
"cal-bg-muted": "var(--cal-bg-muted)",
},
textColor: {
emphasis: "var(--cal-text-emphasis, #111827)",
default: "var(--cal-text, #374151)",
subtle: "var(--cal-text-subtle, #6B7280)",
muted: "var(--cal-text-muted, #9CA3AF)",
inverted: "var(--cal-text-inverted, white)",
info: "var(--cal-text-info, #253985)",
success: "var(--cal-text-success, #285231)",
attention: "var(--cal-text-attention, #73321B)",
error: "var(--cal-text-error, #752522)",
brand: "var(--cal-brand-text,'white')",
// Standard Text
emphasis: "var(--cal-text-emphasis)",
default: "var(--cal-text)",
subtle: "var(--cal-text-subtle)",
muted: "var(--cal-text-muted)",
inverted: "var(--cal-text-inverted)",
// Semantic Text
semantic: {
info: "var(--cal-text-semantic-info)",
success: "var(--cal-text-semantic-success)",
attention: "var(--cal-text-semantic-attention)",
error: "var(--cal-text-semantic-error)",
},
// Semantic Text Emphasis
"semantic-info-emphasis": "var(--cal-text-semantic-info-emphasis)",
"semantic-success-emphasis": "var(--cal-text-semantic-success-emphasis)",
"semantic-attention-emphasis": "var(--cal-text-semantic-attention-emphasis)",
"semantic-error-emphasis": "var(--cal-text-semantic-error-emphasis)",
// Legacy - Consider deprecating
info: "var(--cal-text-info)",
success: "var(--cal-text-success)",
attention: "var(--cal-text-attention)",
error: "var(--cal-text-error)",
brand: "var(--cal-brand-text)",
},
fill: {
emphasis: "var(--cal-text-emphasis, #111827)",
@@ -122,9 +242,6 @@ module.exports = {
drawerSlideLeftAndFade: "drawerSlideLeftAndFade 150ms cubic-bezier(0.16, 1, 0.3, 1)",
drawerSlideRightAndFade: "drawerSlideRightAndFade 150ms ease-in",
},
boxShadow: {
dropdown: "0px 2px 6px -1px rgba(0, 0, 0, 0.08)",
},
borderWidth: {
"booker-width": "var(--cal-border-booker-width, 1px)",
},
@@ -162,6 +279,39 @@ module.exports = {
backgroundImage: {
"gradient-primary": "radial-gradient(162.05% 170% at 109.58% 35%, #667593 0%, #E3E3E3 100%)",
},
boxShadow: {
dropdown: "0px 5px 20px 0px rgba(0, 0, 0, 0.10), 0px 10px 40px 0px rgba(0, 0, 0, 0.03)",
"switch-thumb": "0px 0.8px 0.8px 0px rgba(0, 0, 0, 0.10), 0px 0.8px 3.2px 0px rgba(0, 0, 0, 0.08)",
"solid-gray-rested":
"0px 2px 3px 0px rgba(0, 0, 0, 0.06), 0px 1px 1px 0px rgba(0, 0, 0, 0.08), 1px 4px 8px 0px rgba(0, 0, 0, 0.12), 0px 2px 0.4px 0px rgba(255, 255, 255, 0.16) inset, 0px -1.5px 2px 0px rgba(0, 0, 0, 0.40) inset",
"solid-gray-hover":
"0px 2px 3px 0px rgba(0, 0, 0, 0.06), 0px 1px 1px 0px rgba(0, 0, 0, 0.08), 1px 4px 8px 0px rgba(0, 0, 0, 0.12), 0px 2px 0.4px 0px rgba(255, 255, 255, 0.16) inset, 0px -2px 2px 0px rgba(0, 0, 0, 0.40) inset",
"solid-gray-active":
"0px 2px 3px 0px rgba(0, 0, 0, 0.40) inset, 0px 0px 2px 1px rgba(0, 0, 0, 0.40) inset",
"outline-gray-rested": "0px 2px 3px 0px rgba(0, 0, 0, 0.03), 0px 2px 2px -1px rgba(0, 0, 0, 0.03)",
"outline-gray-hover": "0px 2px 3px 0px rgba(0, 0, 0, 0.03), 0px 2px 2px -1px rgba(0, 0, 0, 0.03)",
"outline-gray-active": "0px 2px 1px 0px rgba(0, 0, 0, 0.05) inset",
"outline-gray-focused":
"0px 0px 0px 1px rgba(255, 255, 255, 0.20), 0px 0px 0px 2px rgba(0, 0, 0, 0.10)",
"outline-red-rested": "0px 2px 3px 0px rgba(0, 0, 0, 0.03), 0px 2px 2px -1px rgba(0, 0, 0, 0.03)",
"outline-red-hover": "0px 1px 1px 0px rgba(0, 0, 0, 0.06), 0px 2px 3px 0px rgba(0, 0, 0, 0.08)",
"outline-red-active":
"0px 1px 1px 0px rgba(127, 29, 29, 0.06), 0px 0px 3px 0px rgba(127, 29, 29, 0.08), 0px 2px 2px 1px rgba(127, 29, 29, 0.06) inset",
"elevation-low":
"0px 1px 1px 0px rgba(0, 0, 0, 0.07), 0px 1px 2px 0px rgba(0, 0, 0, 0.08), 0px 2px 2px 0px rgba(0, 0, 0, 0.10), 0px 0px 8px 0px rgba(0, 0, 0, 0.05)",
// Brand
"button-solid-brand-default":
" 0px 2px 3px 0px rgba(0, 0, 0, 0.06), 0px 1px 1px 0px rgba(0, 0, 0, 0.08), 1px 4px 8px 0px rgba(0, 0, 0, 0.12), 0px 2px 0.4px 0px rgba(255, 255, 255, 0.12) inset, 0px -3px 2px 0px rgba(0, 0, 0, 0.04) inset;",
"button-solid-brand-hover":
"0px 1px 1px 0px rgba(0, 0, 0, 0.10), 0px 2px 3px 0px rgba(0, 0, 0, 0.08), 1px 4px 8px 0px rgba(0, 0, 0, 0.12), 0px -3px 2px 0px rgba(0, 0, 0, 0.10) inset, 0px 2px 0.4px 0px rgba(255, 255, 255, 0.24) inset",
"button-solid-brand-active":
"0px 3px 1px 0px rgba(0, 0, 0, 0.10) inset, 0px 0px 2px 0px rgba(0, 0, 0, 0.10) inset",
"button-solid-brand-focused":
"0px 0px 0px 1px rgba(255, 255, 255, 0.40), 0px 0px 0px 2px rgba(0, 0, 0, 0.20), 0px 1px 1px 0px rgba(0, 0, 0, 0.10), 0px 2px 3px 0px rgba(0, 0, 0, 0.08), 1px 4px 8px 0px rgba(0, 0, 0, 0.12), 0px -3px 2px 0px rgba(0, 0, 0, 0.10) inset, 0px 2px 0.4px 0px rgba(255, 255, 255, 0.24) inset",
// Outline - red
"button-outline-red-focused":
"0px 0px 0px 1px rgba(255, 255, 255, 0.32), 0px 0px 0px 2px rgba(220, 38, 38, 0.15)",
},
},
},
plugins: [
@@ -183,6 +333,9 @@ module.exports = {
},
});
}),
plugin(function ({ addVariant }) {
addVariant("enabled", "&:not(:disabled)");
}),
],
variants: {
scrollbar: ["dark"],
+1 -2
View File
@@ -32,8 +32,7 @@
--cal-text-info: #253985;
--cal-text-success: #285231;
--cal-text-attention: #73321b;
--cal-text-error: #752522;
--cal-text-error: hsla(0, 63%, 31%, 1);
/* Brand shenanigans
-> These will be computed for the users theme at runtime.
*/
@@ -0,0 +1,157 @@
export const addAppCssVars = () => {
try {
const cssVarsStyle = `cal-floating-button, cal-modal-box, cal-inline {
/* Spacing Scale */
--cal-spacing-0: 0px;
--cal-spacing-px: 1px;
--cal-spacing-0_5: 0.125rem; /* 2px */
--cal-spacing-1: 0.25rem; /* 4px */
--cal-spacing-1_5: 0.375rem; /* 6px */
--cal-spacing-2: 0.5rem; /* 8px */
--cal-spacing-2_5: 0.625rem; /* 10px */
--cal-spacing-3: 0.75rem; /* 12px */
--cal-spacing-3_5: 0.875rem; /* 14px */
--cal-spacing-4: 1rem; /* 16px */
--cal-spacing-5: 1.25rem; /* 20px */
--cal-spacing-6: 1.5rem; /* 24px */
--cal-spacing-7: 1.75rem; /* 28px */
--cal-spacing-8: 2rem; /* 32px */
--cal-spacing-9: 2.25rem; /* 36px */
--cal-spacing-10: 2.5rem; /* 40px */
--cal-spacing-11: 2.75rem; /* 44px */
--cal-spacing-12: 3rem; /* 48px */
--cal-spacing-14: 3.5rem; /* 56px */
--cal-spacing-16: 4rem; /* 64px */
--cal-spacing-20: 5rem; /* 80px */
--cal-spacing-24: 6rem; /* 96px */
--cal-spacing-28: 7rem; /* 112px */
--cal-spacing-32: 8rem; /* 128px */
--cal-spacing-36: 9rem; /* 144px */
--cal-spacing-40: 10rem; /* 160px */
--cal-spacing-44: 11rem; /* 176px */
--cal-spacing-48: 12rem; /* 192px */
--cal-spacing-52: 13rem; /* 208px */
--cal-spacing-56: 14rem; /* 224px */
--cal-spacing-60: 15rem; /* 240px */
--cal-spacing-64: 16rem; /* 256px */
--cal-spacing-72: 18rem; /* 288px */
--cal-spacing-80: 20rem; /* 320px */
--cal-spacing-96: 24rem; /* 384px */
/* Border Radius */
--cal-radius-none: 0px;
--cal-radius-sm: 0.125rem; /* 2px */
--cal-radius: 0.25rem; /* 4px */
--cal-radius-md: 0.375rem; /* 6px */
--cal-radius-lg: 0.5rem; /* 8px */
--cal-radius-xl: 0.75rem; /* 12px */
--cal-radius-2xl: 1rem; /* 16px */
--cal-radius-3xl: 1.5rem; /* 24px */
--cal-radius-full: 9999px;
/* Background Standard */
--cal-bg-emphasis: hsla(220, 13%, 91%, 1); /* gray.200 - active items and emphasising */
--cal-bg: hsla(0, 0%, 100%, 1); /* white - default background */
--cal-bg-subtle: hsla(220, 14%, 94%, 1); /* gray.100 - hovering on items, subtle raising */
--cal-bg-muted: hsla(210, 20%, 97%, 1); /* gray.50 - large items, sidebar, sections */
--cal-bg-inverted: hsla(210, 30%, 4%, 1); /* gray.900 - tooltips */
/* Background Primary */
--cal-bg-primary: hsla(214, 30%, 16%, 1); /* stone-100 */
--cal-bg-primary-emphasis: hsla(220, 6%, 25%, 1); /* stone-800 */
--cal-bg-primary-muted: hsla(220, 14%, 94%, 1); /* stone-400 */
/* Background Brand */
--cal-bg-brand: hsla(214, 30%, 16%, 1); /* gray-50 */
--cal-bg-brand-emphasis: hsla(220, 6%, 25%, 1); /* stone-100 */
--cal-bg-brand-muted: hsla(220, 14%, 94%, 1); /* stone-100 */
/* Background Semantic */
--cal-bg-semantic-info-subtle: hsla(212, 88%, 97%, 1); /* blue-100 */
--cal-bg-semantic-info-emphasis: hsla(236, 80%, 25%, 1); /* blue-500 */
--cal-bg-semantic-success-subtle: hsla(167, 54%, 93%, 1); /* green-100 */
--cal-bg-semantic-success-emphasis: hsla(158, 74%, 38%, 1); /* green-500 */
--cal-bg-semantic-attention-subtle: hsla(34, 100%, 92%, 1); /* orange-100 */
--cal-bg-semantic-attention-emphasis: hsla(15, 79%, 34%, 1); /* orange-500 */
--cal-bg-semantic-error-subtle: hsla(0, 93%, 94%, 1); /* red-100 */
--cal-bg-semantic-error-emphasis: hsla(0, 63%, 24%, 1); /* red-500 */
/* Background Visualization */
--cal-bg-visualization-1-subtle: hsla(326, 78%, 95%, 1); /* pink-100 */
--cal-bg-visualization-1-emphasis: hsla(330, 81%, 60%, 1); /* pink-500 */
--cal-bg-visualization-2-subtle: hsla(256, 86%, 91%, 1); /* purple-100 */
--cal-bg-visualization-2-emphasis: hsla(256, 85%, 57%, 1); /* purple-500 */
--cal-bg-visualization-3-subtle: hsla(217, 87%, 91%, 1); /* blue-100 */
--cal-bg-visualization-3-emphasis: hsla(235, 100%, 63%, 1); /* blue-500 */
--cal-bg-visualization-4-subtle: hsla(167, 54%, 93%, 1); /* green-100 */
--cal-bg-visualization-4-emphasis: hsla(158, 74%, 38%, 1); /* green-500 */
--cal-bg-visualization-5-subtle: hsla(55, 97%, 88%, 1); /* yellow-100 */
--cal-bg-visualization-5-emphasis: hsla(45, 93%, 47%, 1); /* yellow-500 */
--cal-bg-visualization-6-subtle: hsla(34, 100%, 92%, 1); /* orange-100 */
--cal-bg-visualization-6-emphasis: hsla(25, 95%, 53%, 1); /* orange-500 */
--cal-bg-visualization-7-subtle: hsla(0, 96%, 89%, 1); /* red-100 */
--cal-bg-visualization-7-emphasis: hsla(0, 84%, 60%, 1); /* red-500 */
/* Legacy Background Components - Consider deprecating */
--cal-bg-info: hsla(221, 91%, 93%, 1); /* #dee9fc - info backgrounds */
--cal-bg-success: hsla(142, 76%, 94%, 1); /* #e2fbe8 - success backgrounds */
--cal-bg-attention: hsla(33, 100%, 92%, 1); /* #fceed8 - attention backgrounds */
--cal-bg-error: hsla(3, 66%, 93%, 1); /* #f9e3e2 - error backgrounds */
--cal-bg-dark-error: hsla(2, 55%, 30%, 1); /* Keeping existing dark error */
/* Borders */
--cal-border-emphasis: hsla(218, 11%, 65%, 1); /* gray.400 - input:hover */
--cal-border: hsla(216, 12%, 84%, 1); /* gray.300 - inputs */
--cal-border-subtle: hsla(220, 13%, 91%, 1); /* gray.200 - container borders */
--cal-border-muted: hsla(220, 14%, 94%, 1); /* gray.100 */
--cal-border-error: hsla(0, 96%, 89%, 1); /* Keeping existing error border */
--cal-border-semantic-error: hsla(0, 96%, 89%, 1);
--cal-border-booker: var(--cal-border-subtle);
/* Content/Text Standard */
--cal-text-emphasis: hsla(210, 30%, 4%, 1); /* gray-900 */
--cal-text: hsla(220, 6%, 25%, 1); /* gray-700 */
--cal-text-subtle: hsla(220, 9%, 46%, 1); /* gray-500 */
--cal-text-muted: hsla(218, 11%, 65%, 1); /* gray-400 */
--cal-text-inverted: hsla(0, 0%, 100%, 1); /* white */
/* Content/Text Semantic */
--cal-text-semantic-info: hsla(236, 80%, 25%, 1); /* blue-800 */
--cal-text-semantic-success: hsla(150, 84%, 22%, 1); /* green-800 */
--cal-text-semantic-attention: hsla(15, 79%, 34%, 1); /* orange-800 */
--cal-text-semantic-error: hsla(0, 63%, 24%, 1); /* red-800 */
/* Content/Text Visualization */
--cal-text-visualization-1: hsla(332, 79%, 25%, 1); /* pink-800 */
--cal-text-visualization-2: hsla(270, 91%, 25%, 1); /* purple-800 */
--cal-text-visualization-3: hsla(217, 91%, 25%, 1); /* blue-800 */
--cal-text-visualization-4: hsla(142, 71%, 25%, 1); /* green-800 */
--cal-text-visualization-5: hsla(45, 93%, 25%, 1); /* yellow-800 */
--cal-text-visualization-6: hsla(24, 95%, 25%, 1); /* orange-800 */
--cal-text-visualization-7: hsla(0, 84%, 25%, 1); /* red-800 */
/* Border/Semantic Subtle */
--cal-border-semantic-attention-subtle: hsla(32, 98%, 83%, 1);
--cal-border-semantic-error-subtle: hsla(0, 96%, 89%, 1);
/* Legacy Content/Text Components - Consider deprecating */
--cal-text-info: hsla(225, 57%, 33%, 1); /* #253985 - interactive text/icons */
--cal-text-success: hsla(144, 34%, 24%, 1); /* #285231 */
--cal-text-attention: hsla(16, 62%, 28%, 1); /* Keeping existing attention text */
--cal-text-error: hsla(0, 63%, 31%, 1); /* Keeping existing error text */
/* Brand */
--cal-brand: hsla(221, 39%, 11%, 1); /* Keeping existing brand color */
--cal-brand-emphasis: hsla(0, 0%, 6%, 1); /* Keeping existing brand emphasis */
--cal-brand-text: hsla(0, 0%, 100%, 1); /* white */
}`;
// Create a style rule for above css
const style = document.createElement("style");
style.id = "cal-css-vars";
style.textContent = cssVarsStyle;
document.head.appendChild(style);
} catch (error) {
console.error("Error adding app css vars - Report this issue to support", error);
}
};
+3
View File
@@ -2,6 +2,7 @@
import { FloatingButton } from "./FloatingButton/FloatingButton";
import { Inline } from "./Inline/inline";
import { ModalBox } from "./ModalBox/ModalBox";
import { addAppCssVars } from "./addAppCssVars";
import type { InterfaceWithParent, interfaceWithParent, PrefillAndIframeAttrsConfig } from "./embed-iframe";
import css from "./embed.css";
import { SdkActionManager } from "./sdk-action-manager";
@@ -1056,6 +1057,8 @@ function initializeGlobalCalProps() {
globalCal.config.forwardQueryParams = globalCal.config.forwardQueryParams ?? false;
}
addAppCssVars();
function log(...args: unknown[]) {
console.log(...args);
}
@@ -214,7 +214,8 @@ export const EventMeta = ({
menuPosition="absolute"
timezoneSelectCustomClassname={classNames?.eventMetaTimezoneSelect}
classNames={{
control: () => "!min-h-0 p-0 w-full border-0 bg-transparent focus-within:ring-0",
control: () =>
"!min-h-0 p-0 w-full border-0 bg-transparent focus-within:ring-0 shadow-none!",
menu: () => "!w-64 max-w-[90vw] mb-1 ",
singleValue: () => "text-text py-1",
indicatorsContainer: () => "ml-auto",
@@ -2,7 +2,7 @@ import type { Dispatch, SetStateAction } from "react";
import { useFilterQuery } from "@calcom/features/bookings/lib/useFilterQuery";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Badge, Button, Icon, Tooltip } from "@calcom/ui";
import { Badge, Button, Tooltip } from "@calcom/ui";
export interface FilterToggleProps {
setIsFiltersVisible: Dispatch<SetStateAction<boolean>>;
@@ -19,8 +19,7 @@ export function FilterToggle({ setIsFiltersVisible }: FilterToggleProps) {
}
return (
<Button color="secondary" onClick={toggleFiltersVisibility} className="mb-4">
<Icon name="filter" className="h-4 w-4" />
<Button color="secondary" onClick={toggleFiltersVisibility} className="mb-4" StartIcon="filter">
<Tooltip content={t("filters")}>
<div className="mx-2">{t("filters")}</div>
</Tooltip>
@@ -28,7 +28,7 @@ export function FiltersContainer({ isFiltersVisible }: FiltersContainerProps) {
return (
<div ref={animationParentRef}>
{isFiltersVisible ? (
<div className="no-scrollbar flex w-full space-x-2 overflow-x-scroll rtl:space-x-reverse">
<div className="no-scrollbar mb-2 flex w-full space-x-2 overflow-x-scroll rtl:space-x-reverse">
<PeopleFilter />
<EventTypeFilter />
<TeamsFilter />
@@ -5,7 +5,7 @@ import { forwardRef } from "react";
import { classNames } from "@calcom/lib";
import { Button, Icon } from "@calcom/ui";
import type { IconName } from "@calcom/ui";
import type { IconName, ButtonProps } from "@calcom/ui";
export type ActionItem<TData> =
| {
@@ -26,12 +26,12 @@ type ResponsiveButtonProps = {
icon: IconName;
onClick?: () => void;
children: string;
};
} & ButtonProps;
const ResponsiveButton = forwardRef<HTMLButtonElement, ResponsiveButtonProps>(
({ className, icon, onClick, children }, ref) => {
({ icon, onClick, children, ...rest }, ref) => {
return (
<Button ref={ref} onClick={onClick} title={children}>
<Button ref={ref} onClick={onClick} title={children} {...rest}>
<Icon name={icon} size={18} className="sm:hidden" />
<Icon name={icon} size={16} className="mr-2 hidden shrink-0 sm:inline" />
<span className="sr-only shrink-0 md:not-sr-only">{children}</span>
@@ -51,7 +51,7 @@ const Root = forwardRef<
<div
ref={ref}
className={classNames(
"bg-brand-default text-brand fixed bottom-0 left-0 z-40 flex w-full items-center space-x-1 overflow-x-auto px-2 py-2 sm:space-x-2 md:bottom-4 md:left-1/2 md:z-auto md:w-fit md:-translate-x-1/2 md:transform md:space-x-3 md:overflow-x-hidden md:rounded-lg md:px-4",
"bg-default text-emphasis shadow-outline-gray-rested fixed bottom-0 left-0 z-40 flex w-full items-center space-x-1 overflow-x-auto border px-2 py-2 sm:space-x-2 md:bottom-4 md:left-1/2 md:z-auto md:w-fit md:-translate-x-1/2 md:transform md:space-x-3 md:overflow-x-hidden md:rounded-lg md:px-4",
className
)}
style={{ ...style }}
@@ -47,8 +47,12 @@ function AddFilterButtonComponent<TData>(
<div className="flex items-center space-x-2">
<Popover>
<PopoverTrigger asChild>
<Button ref={ref} color="secondary" data-testid="add-filter-button">
<Icon name="sliders-horizontal" className="mr-2 h-4 w-4" />
<Button
ref={ref}
color="secondary"
data-testid="add-filter-button"
StartIcon="sliders-horizontal"
className="h-full">
{t("filter")}
</Button>
</PopoverTrigger>
@@ -1,6 +1,6 @@
import { useDataTable } from "@calcom/features/data-table";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Icon, Button, Tooltip } from "@calcom/ui";
import { Button, Tooltip } from "@calcom/ui";
export const ClearFiltersButton = ({ exclude }: { exclude?: string[] }) => {
const { t } = useLocale();
@@ -13,14 +13,13 @@ export const ClearFiltersButton = ({ exclude }: { exclude?: string[] }) => {
return (
<Tooltip content={t("clear_filters")}>
<Button
color="minimal"
data-testid="clear-filters-button"
variant="icon"
color="secondary"
target="_blank"
rel="noreferrer"
className="min-w-24 h-[38px] border-0"
className="min-w-24"
StartIcon="x"
onClick={() => clearAll(exclude)}>
<Icon name="x" className="mr-1 h-4 w-4" />
{t("clear")}
</Button>
</Tooltip>
@@ -147,7 +147,7 @@ export const DateRangeFilter = ({ column }: DateRangeFilterProps) => {
return (
<Popover>
<PopoverTrigger asChild>
<Button color="secondary" className="items-center capitalize">
<Button color="secondary" className="items-center capitalize" EndIcon="chevron-down">
{!isCustomPreset && <span>{t(selectedPreset.labelKey, selectedPreset.i18nOptions)}</span>}
{isCustomPreset &&
(endDate ? (
@@ -157,7 +157,6 @@ export const DateRangeFilter = ({ column }: DateRangeFilterProps) => {
) : (
<span>{format(startDate.toDate(), "LLL dd, y")} - End</span>
))}
<Icon name="chevron-down" className="ml-2 h-4 w-4" />
</Button>
</PopoverTrigger>
<PopoverContent className="flex w-fit p-0" align="end">
@@ -2,7 +2,7 @@
import startCase from "lodash/startCase";
import type { IconName } from "@calcom/ui";
import { Button, Icon, Popover, PopoverContent, PopoverTrigger, Badge } from "@calcom/ui";
import { Button, Popover, PopoverContent, PopoverTrigger, Badge } from "@calcom/ui";
import { useFilterValue } from "../../hooks";
import { type FilterableColumn, type FilterValue, ZFilterValue, ColumnFilterType } from "../../lib/types";
@@ -137,11 +137,11 @@ export function FilterPopover({ column }: FilterPopoverProps) {
<Button
color="secondary"
className="items-center"
StartIcon={icon}
EndIcon="chevron-down"
data-testid={`filter-popover-trigger-${column.id}`}>
<Icon name={icon} className="mr-2 h-4 w-4" />
<span>{startCase(column.title)}</span>
<AppliedFilterValue column={column} filterValue={filterValue} />
<Icon name="chevron-down" className="ml-2 h-4 w-4" />
</Button>
</PopoverTrigger>
<PopoverContent className="p-0" align="start">
@@ -31,7 +31,7 @@ export const LockedSwitch = (
setUnlockedFields(fieldName, !enabled || undefined);
}}
checked={fieldState[fieldName]}
small={!options.simple}
size="sm"
/>
) : null;
};
@@ -58,7 +58,7 @@ export const LockedIndicator = (
<Badge
variant={isLocked ? "gray" : "green"}
className={classNames(
"ml-2 transform justify-between gap-1.5 p-1",
"ml-2 transform justify-between p-1",
isManagedEventType && !options.simple && "w-28"
)}>
{!options.simple && (
@@ -78,7 +78,7 @@ export const LockedIndicator = (
setUnlockedFields(fieldName, !enabled || undefined);
}}
checked={isLocked}
small={!options.simple}
size="sm"
/>
)}
</Badge>
@@ -236,7 +236,8 @@ const AddNewTeamsFormChild = ({
disabled={createTeamsMutation.isPending}
onClick={handleCounterIncrease}
aria-label={t("add_a_team")}
className="my-1">
className="my-1"
data-testId="add_a_team">
{t("add_a_team")}
</Button>
)}
@@ -120,7 +120,6 @@ export const CreateANewTeamForm = (props: CreateANewTeamFormProps) => {
rules={{ required: t("team_url_required") }}
render={({ field: { value } }) => (
<TextField
className="mt-2"
name="slug"
placeholder="acme"
label={t("team_url")}
@@ -31,7 +31,9 @@ export default function DeleteBulkTeamMembers({ users, onRemove, isOrg, teamId }
return (
<Dialog>
<DialogTrigger asChild>
<DataTableSelectionBar.Button icon="ban">{t("Delete")}</DataTableSelectionBar.Button>
<DataTableSelectionBar.Button icon="ban" color="destructive">
{t("Delete")}
</DataTableSelectionBar.Button>
</DialogTrigger>
<ConfirmationDialogContent
variety="danger"
@@ -94,7 +94,9 @@ export function EventTypesList({ table, teamId }: Props) {
<>
<Popover>
<PopoverTrigger asChild>
<DataTableSelectionBar.Button icon="link">{t("add_to_event_type")}</DataTableSelectionBar.Button>
<DataTableSelectionBar.Button icon="link" color="secondary">
{t("add_to_event_type")}
</DataTableSelectionBar.Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0 shadow-md" align="start" sideOffset={12}>
<Command>
@@ -433,8 +433,8 @@ export default function MemberInvitationModal(props: MemberInvitationModalProps)
}
}}
className={classNames("gap-2", props.token && "opacity-50")}
StartIcon="link"
data-testid="copy-invite-link-button">
<Icon name="link" className="text-default h-4 w-4" aria-hidden="true" />
<span className="hidden sm:inline">{t("copy_invite_link")}</span>
</Button>
</div>
@@ -674,7 +674,6 @@ function MemberListContent(props: Props) {
type="button"
color="primary"
StartIcon="plus"
className="rounded-md"
onClick={() => props.setShowMemberInvitationModal(true)}
data-testid="new-member-button">
{t("add")}
@@ -698,6 +697,7 @@ function MemberListContent(props: Props) {
</p>
{numberOfSelectedRows >= 2 && (
<DataTableSelectionBar.Button
color="secondary"
onClick={() => setDynamicLinkVisible(!dynamicLinkVisible)}
icon="handshake">
{t("group_meeting")}
@@ -91,8 +91,8 @@ const ProfileView = ({ team }: ProfileViewProps) => {
}}>
<div className="border-subtle mt-6 flex items-center rounded-t-xl border p-6 text-sm">
<div>
<p className="font-semibold">{t("theme")}</p>
<p className="text-default">{t("theme_applies_note")}</p>
<p className="mt-0.5 text-base font-semibold leading-none">{t("theme")}</p>
<p className="text-default text-sm leading-normal">{t("theme_applies_note")}</p>
</div>
</div>
<div className="border-subtle flex flex-col justify-between border-x px-6 py-8 sm:flex-row">
@@ -1,11 +1,8 @@
"use client";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { TeamsListing } from "../components";
const TeamListingView = () => {
const { t } = useLocale();
return <TeamsListing />;
};
@@ -64,7 +64,7 @@ export const TimeTimeUnitInput = (props: Props) => {
label=""
disabled={props.disabled}
defaultValue={form.getValues("time") ?? props.defaultTime ?? 24}
className="-mt-2 rounded-r-none text-sm focus:ring-0"
className="rounded-r-none text-sm focus:ring-0"
{...form.register("time", { valueAsNumber: true })}
addOnSuffix={
<TimeUnitAddonSuffix
@@ -239,7 +239,7 @@ export default function WorkflowListPage({ workflows }: Props) {
workflow?.team.logo,
workflow.team?.name as string
)}
size="xxs"
size="xs"
className="mt-[3px] inline-flex justify-center"
/>
<div>{workflow.team.name}</div>
@@ -917,7 +917,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
emailSubjectFormRef?.(e);
refEmailSubject.current = e;
}}
rows={1}
rows={2}
disabled={props.readOnly || !hasActiveTeamPlan}
className="my-0 focus:ring-transparent"
required
@@ -21,6 +21,7 @@ export const tabs = [
href: "embedTabName=embed-code",
icon: "code" as const,
type: "code",
"data-testid": "HTML",
Component: forwardRef<
HTMLTextAreaElement | HTMLIFrameElement | null,
{ embedType: EmbedType; calLink: string; previewState: PreviewState; namespace: string }
@@ -75,6 +76,7 @@ export const tabs = [
{
name: "React",
href: "embedTabName=embed-react",
"data-testid": "react",
icon: "code" as const,
type: "code",
Component: forwardRef<
@@ -126,6 +128,7 @@ export const tabs = [
href: "embedTabName=embed-preview",
icon: "trello" as const,
type: "iframe",
"data-testid": "Preview",
Component: forwardRef<
HTMLIFrameElement | HTMLTextAreaElement | null,
{ calLink: string; embedType: EmbedType; previewState: PreviewState; namespace: string }
@@ -2,20 +2,20 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
const SkeletonEventType = () => {
return (
<div className="dark:bg-darkgray-100 bg-default h-24 w-full">
<div className="bg-default h-24 w-full">
<div className="p-5">
<div className="flex space-x-2 rtl:space-x-reverse">
<div className="dark:bg-darkgray-400 h-2 w-1/6 rounded-md bg-neutral-200" />
<div className="dark:bg-darkgray-400 h-2 w-1/6 rounded-md bg-neutral-200" />
<div className="bg-subtle h-2 w-1/6 rounded-md" />
<div className="bg-subtle h-2 w-1/6 rounded-md" />
</div>
<div className="flex space-x-2 py-2 rtl:space-x-reverse">
<div className="dark:bg-darkgray-400 h-2 w-1/12 rounded-md bg-neutral-200" />
<div className="dark:bg-darkgray-400 h-2 w-1/6 rounded-md bg-neutral-200" />
<div className="dark:bg-darkgray-400 h-2 w-1/12 rounded-md bg-neutral-200" />
<div className="bg-subtle h-2 w-1/12 rounded-md" />
<div className="bg-subtle h-2 w-1/6 rounded-md" />
<div className="bg-subtle h-2 w-1/12 rounded-md" />
</div>
<div className="flex space-x-2 py-1 rtl:space-x-reverse">
<div className="dark:bg-darkgray-200 h-6 w-1/6 rounded-md bg-neutral-300" />
<div className="dark:bg-darkgray-200 h-6 w-1/6 rounded-md bg-neutral-300" />
<div className="bg-subtle h-6 w-1/6 rounded-md" />
<div className="bg-subtle h-6 w-1/6 rounded-md" />
</div>
</div>
</div>
@@ -26,7 +26,7 @@ function EmptyPage({ name }: { name: string }) {
const { t } = useLocale();
return (
<div className="relative text-center">
<div className="dark:divide-darkgray-100 flex flex-col divide-y-2 blur-[3px]">
<div className="flex flex-col divide-y-2 blur-[3px]">
<SkeletonEventType />
<SkeletonEventType />
<SkeletonEventType />
@@ -55,7 +55,6 @@ export const MultiplePrivateLinksController = ({
color="minimal"
size="sm"
type="button"
className="hover:stroke-3 hover:text-emphasis min-w-fit !py-0 px-0 hover:bg-transparent"
aria-label="copy link"
onClick={() => {
navigator.clipboard.writeText(singleUseURL);
@@ -184,7 +184,7 @@ export default function RequiresConfirmationController({
);
}}
className={classNames(
"border-default !m-0 block w-16 rounded-r-none border-r-0 text-sm [appearance:textfield] focus:z-10 focus:border-r",
"border-default h-8! !m-0 block w-16 rounded-r-none border-r-0 text-sm [appearance:textfield] focus:z-10 focus:border-r",
customClassNames?.conditionalConfirmationRadio?.timeInput
)}
defaultValue={metadata?.requiresConfirmationThreshold?.time || 30}
@@ -92,7 +92,7 @@ export const EventAppsTab = ({ eventType }: { eventType: EventType }) => {
<div className="before:border-0">
{(isManagedEventType || isChildrenManagedEventType) && (
<Alert
severity={appsDisableProps.isLocked ? "neutral" : "green"}
severity={appsDisableProps.isLocked ? "neutral" : "info"}
className="mb-2"
title={
<Trans i18nKey={`${lockedText}_${isManagedEventType ? "for_members" : "by_team_admins"}`}>
@@ -576,7 +576,7 @@ const UseCommonScheduleSettingsToggle = ({
const { t } = useLocale();
const { useHostSchedulesForTeamEvent, toggleScheduleState } = useCommonScheduleState(eventType.schedule);
return (
<>
<div className="border-subtle space-y-6 rounded-lg border p-6">
<SettingsToggle
checked={!useHostSchedulesForTeamEvent}
onCheckedChange={toggleScheduleState}
@@ -598,7 +598,7 @@ const UseCommonScheduleSettingsToggle = ({
/>
</div>
)}
</>
</div>
);
};
@@ -327,7 +327,7 @@ const MinimumBookingNoticeInput = React.forwardRef<
label={t("minimum_booking_notice")}
type="number"
placeholder="0"
className={classNames("mb-0 h-9 rounded-[4px] ltr:mr-2 rtl:ml-2", customClassNames?.input)}
className={classNames("mb-0 h-9 ltr:mr-2 rtl:ml-2", customClassNames?.input)}
min={0}
/>
<input type="hidden" ref={ref} {...passThroughProps} />
@@ -115,7 +115,7 @@ export const EventWebhooksTab = ({ eventType }: Pick<EventTypeSetupProps, "event
<>
{(isManagedEventType || isChildrenManagedEventType) && (
<Alert
severity={webhooksDisableProps.isLocked ? "neutral" : "green"}
severity={webhooksDisableProps.isLocked ? "neutral" : "info"}
className="mb-2"
title={
<Trans
@@ -132,9 +132,8 @@ const WorkflowListItem = (props: ItemProps) => {
{!workflow.readOnly && (
<div className="flex-none">
<Link href={`/workflows/${workflow.id}`} passHref={true} target="_blank">
<Button type="button" color="minimal" className="mr-4">
<Button type="button" color="minimal" className="mr-4" EndIcon="external-link">
<div className="hidden ltr:mr-2 rtl:ml-2 sm:block">{t("edit")}</div>
<Icon name="external-link" className="text-default -mt-[2px] h-4 w-4 stroke-2" />
</Button>
</Link>
</div>
@@ -244,7 +243,7 @@ function EventWorkflowsTab(props: Props) {
<>
{(isManagedEventType || isChildrenManagedEventType) && (
<Alert
severity={workflowsDisableProps.isLocked ? "neutral" : "green"}
severity={workflowsDisableProps.isLocked ? "neutral" : "info"}
className="mb-2"
title={
<Trans i18nKey={`${lockedText}_${isManagedEventType ? "for_members" : "by_team_admins"}`}>
@@ -236,8 +236,6 @@ export const Components: Record<FieldType, Component> = {
const placeholder = props.placeholder;
const { t } = useLocale();
value = value || [];
const inputClassName =
"dark:placeholder:text-muted focus:border-emphasis border-subtle block w-full rounded-md border-default text-sm focus:ring-black disabled:bg-emphasis disabled:hover:cursor-not-allowed dark:selection:bg-green-500 disabled:dark:text-subtle bg-default";
return (
<>
{value.length ? (
@@ -252,7 +250,6 @@ export const Components: Record<FieldType, Component> = {
id={`${props.name}.${index}`}
disabled={readOnly}
value={value[index]}
className={inputClassName}
onChange={(e) => {
value[index] = e.target.value.toLowerCase();
setValue(value);
@@ -353,7 +350,7 @@ export const Components: Record<FieldType, Component> = {
}
setValue(newValue);
}}
className="border-default dark:border-default hover:bg-subtle checked:hover:bg-brand-default checked:bg-brand-default dark:checked:bg-brand-default dark:bg-darkgray-100 dark:hover:bg-subtle dark:checked:hover:bg-brand-default h-4 w-4 cursor-pointer rounded transition ltr:mr-2 rtl:ml-2"
className="border-default dark:border-default hover:bg-subtle checked:hover:bg-brand-default checked:bg-brand-default dark:checked:bg-brand-default dark:hover:bg-subtle dark:checked:hover:bg-brand-default h-4 w-4 cursor-pointer rounded transition ltr:mr-2 rtl:ml-2"
value={option.value}
checked={value.includes(option.value)}
/>
@@ -248,7 +248,6 @@ export const FormBuilder = function FormBuilder({
onCheckedChange={(checked) => {
update(index, { ...field, hidden: !checked });
}}
classNames={{ container: "p-2 hover:bg-subtle rounded transition" }}
tooltip={t("show_on_booking_page")}
/>
)}
@@ -487,12 +486,9 @@ function FieldEditDialog({
return (
<Dialog open={dialog.isOpen} onOpenChange={onOpenChange} modal={false}>
<DialogContent
className="max-h-none p-0"
data-testid="edit-field-dialog"
forceOverlayWhenNoModal={true}>
<DialogContent className="max-h-none" data-testid="edit-field-dialog" forceOverlayWhenNoModal={true}>
<Form id="form-builder" form={fieldForm} handleSubmit={handleSubmit}>
<div className="h-auto max-h-[85vh] overflow-auto px-8 pb-7 pt-8">
<div className="h-auto max-h-[85vh] overflow-auto">
<DialogHeader title={t("add_a_booking_question")} subtitle={t("booking_questions_description")} />
<SelectField
defaultValue={fieldTypesConfigMap.text}
@@ -648,7 +644,7 @@ function FieldEditDialog({
})()}
</div>
<DialogFooter className="relative rounded px-8" showDivider>
<DialogFooter className="relative">
<DialogClose color="secondary">{t("cancel")}</DialogClose>
<Button data-testid="field-add-save" type="submit">
{isFieldEditMode ? t("save") : t("add")}
@@ -805,7 +801,7 @@ function VariantFields({
onCheckedChange={(checked) => {
fieldForm.setValue("variant", checked ? otherVariant : defaultVariant);
}}
classNames={{ container: "p-2 mt-2 sm:hover:bg-muted rounded transition" }}
classNames={{ container: "mt-2" }}
tooltip={t("Toggle Variant")}
/>
) : (
@@ -249,6 +249,7 @@ export const ComponentForField = ({
`Value ${value} is not valid for type ${componentConfig.propsType} for field ${field.name}`
);
}
if (componentConfig.propsType === "text") {
return (
<WithLabel field={field} htmlFor={field.name} readOnly={readOnly} noLabel={noLabel}>
@@ -44,7 +44,7 @@ const Download = () => {
EndIcon="file-down"
color="secondary"
{...(isPending && { loading: isPending })}
className="self-end sm:self-baseline">
className="h-full self-end sm:self-baseline">
{t("download")}
</Button>
</DropdownMenuTrigger>
@@ -73,7 +73,7 @@ export const OrgTeamsFilter = () => {
<Avatar
alt={`${placeholder} logo`}
imageSrc={getPlaceholderAvatar(imageUrl, placeholder)}
size="xsm"
size="xs"
className="mr-2"
/>
) : null;
@@ -43,8 +43,8 @@ export function ScheduleListItem({
return (
<li key={schedule.id}>
<div className="hover:bg-muted flex items-center justify-between py-5 transition ltr:pl-4 rtl:pr-4 sm:ltr:pl-0 sm:rtl:pr-0">
<div className="group flex w-full items-center justify-between sm:px-6">
<div className="hover:bg-muted flex items-center justify-between px-3 py-5 transition sm:px-4">
<div className="group flex w-full items-center justify-between ">
<Link
href={`/availability/${schedule.id}`}
className="flex-grow truncate text-sm"
@@ -87,7 +87,6 @@ export function ScheduleListItem({
<DropdownMenuTrigger asChild>
<Button
data-testid="schedule-more"
className="mx-5"
type="button"
variant="icon"
color="secondary"
@@ -96,8 +95,8 @@ export function ScheduleListItem({
</DropdownMenuTrigger>
{!isPending && data && (
<DropdownMenuContent>
<DropdownMenuItem className="min-w-40 focus:ring-muted">
{!schedule.isDefault && (
{!schedule.isDefault && (
<DropdownMenuItem className="min-w-40 focus:ring-muted">
<DropdownItem
type="button"
StartIcon="star"
@@ -109,8 +108,8 @@ export function ScheduleListItem({
}}>
{t("set_as_default")}
</DropdownItem>
)}
</DropdownMenuItem>
</DropdownMenuItem>
)}
<DropdownMenuItem className="outline-none">
<DropdownItem
type="button"
@@ -4,11 +4,18 @@ import { useSearchParams } from "next/navigation";
import { useState, useEffect } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button, Icon } from "@calcom/ui";
import type { ButtonProps } from "@calcom/ui";
import { Button } from "@calcom/ui";
import { CreateOrEditOutOfOfficeEntryModal } from "./CreateOrEditOutOfOfficeModal";
const CreateNewOutOfOfficeEntry = () => {
const CreateNewOutOfOfficeEntry = ({
size,
...rest
}: {
size?: ButtonProps["size"];
"data-testid"?: string;
}) => {
const { t } = useLocale();
const params = useSearchParams();
@@ -25,10 +32,12 @@ const CreateNewOutOfOfficeEntry = () => {
<>
<Button
color="primary"
size={size ?? "base"}
className="flex items-center justify-between px-4"
StartIcon="plus"
onClick={() => setOpenModal(true)}
data-testid="add_entry_ooo">
<Icon name="plus" size={16} /> {t("add")}
data-testid={rest["data-testid"]}>
{t("add")}
</Button>
{openModal && (
<CreateOrEditOutOfOfficeEntryModal
@@ -140,6 +140,7 @@ export const CreateOrEditOutOfOfficeEntryModal = ({
}
}}>
<DialogContent
enableOverflow
onOpenAutoFocus={(event) => {
event.preventDefault();
}}>
@@ -245,7 +246,7 @@ export const CreateOrEditOutOfOfficeEntryModal = ({
onChange={(e) => setSearchText(e.target.value)}
value={searchText}
/>
<div className="scroll-bar flex h-[150px] flex-col gap-0.5 overflow-y-scroll rounded-md border p-1">
<div className="scroll-bar bg-default mt-2 flex h-[150px] flex-col gap-0.5 overflow-y-scroll rounded-[10px] border p-1">
{memberListOptions.map((member) => (
<label
key={member.value}
@@ -20,6 +20,7 @@ import {
Tooltip,
} from "@calcom/ui";
import CreateNewOutOfOfficeEntryButton from "./CreateNewOutOfOfficeEntryButton";
import { CreateOrEditOutOfOfficeEntryModal } from "./CreateOrEditOutOfOfficeModal";
import type { BookingRedirectForm } from "./CreateOrEditOutOfOfficeModal";
@@ -53,6 +54,7 @@ export const OutOfOfficeEntriesList = () => {
className="mt-6"
headline={t("ooo_empty_title")}
description={t("ooo_empty_description")}
buttonRaw={<CreateNewOutOfOfficeEntryButton size="sm" />}
customIcon={
<div className="mt-4 h-[102px]">
<div className="flex h-full flex-col items-center justify-center p-2 md:mt-0 md:p-0">
@@ -63,7 +65,7 @@ export const OutOfOfficeEntriesList = () => {
<div className="dark:bg-darkgray-50 absolute -top-3 left-3 -z-10 h-[70px] w-[70px] rotate-[24deg] rounded-3xl border-2 border-[#e5e7eb] p-8 opacity-60 dark:opacity-90">
<div className="w-12" />
</div>
<div className="dark:bg-darkgray-50 relative z-0 flex h-[70px] w-[70px] items-center justify-center rounded-3xl border-2 border-[#e5e7eb] bg-white">
<div className="dark:bg-darkgray-50 text-inverted relative z-0 flex h-[70px] w-[70px] items-center justify-center rounded-3xl border-2 border-[#e5e7eb] bg-white">
<Icon name="clock" size={28} />
<div className="dark:bg-darkgray-50 absolute right-4 top-5 h-[12px] w-[12px] rotate-[56deg] bg-white text-lg font-bold" />
<span className="absolute right-4 top-3 font-sans text-sm font-extrabold">z</span>
@@ -121,7 +123,7 @@ export const OutOfOfficeEntriesList = () => {
<Button
className="self-center rounded-lg border"
type="button"
color="minimal"
color="secondary"
variant="icon"
data-testid={`ooo-edit-${item.toUser?.username || "n-a"}`}
StartIcon="pencil"
@@ -146,7 +148,7 @@ export const OutOfOfficeEntriesList = () => {
<Button
className="self-center rounded-lg border"
type="button"
color="minimal"
color="destructive"
variant="icon"
disabled={deleteOutOfOfficeEntryMutation.isPending}
StartIcon="trash-2"
@@ -39,7 +39,9 @@ export function DeleteBulkUsers({ users, onRemove }: Props) {
return (
<Dialog>
<DialogTrigger asChild>
<DataTableSelectionBar.Button icon="ban">{t("Delete")}</DataTableSelectionBar.Button>
<DataTableSelectionBar.Button icon="ban" color="destructive">
{t("Delete")}
</DataTableSelectionBar.Button>
</DialogTrigger>
<ConfirmationDialogContent
variety="danger"
@@ -35,11 +35,17 @@ export function DynamicLink<T extends { username: string | null }>({
<div className="items-center truncate p-2 md:max-w-[300px]">
<p className="text-center md:text-left">{domainWithoutHttps}</p>
</div>
<div className="ml-auto flex items-center justify-center md:justify-start">
<Button StartIcon="copy" size="sm" onClick={() => copyToClipboard(dynamicLinkOfSelectedUsers)}>
{!isCopied ? t("copy") : t("copied")}
<div className="ml-auto flex items-center justify-center gap-1 md:justify-start">
<Button
variant="icon"
StartIcon={isCopied ? "check" : "copy"}
size="sm"
onClick={() => copyToClipboard(dynamicLinkOfSelectedUsers)}
color="secondary">
<span className="sr-only">{!isCopied ? t("copy") : t("copied")}</span>
</Button>
<Button
color="secondary"
EndIcon="external-link"
size="sm"
href={dynamicLinkOfSelectedUsers}
@@ -98,7 +98,9 @@ export function EventTypesList({ table, orgTeams }: Props) {
<>
<Popover>
<PopoverTrigger asChild>
<DataTableSelectionBar.Button icon="link">{t("add_to_event_type")}</DataTableSelectionBar.Button>
<DataTableSelectionBar.Button icon="link" color="secondary">
{t("add_to_event_type")}
</DataTableSelectionBar.Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0 shadow-md" align="start" sideOffset={12}>
<Command>
@@ -332,7 +332,9 @@ function MassAssignAttributesBulkActionComponent({ table, filters }: Props) {
}
}}>
<PopoverTrigger asChild>
<DataTableSelectionBar.Button icon="tags">{t("add_attributes")}</DataTableSelectionBar.Button>
<DataTableSelectionBar.Button icon="tags" color="secondary">
{t("add_attributes")}
</DataTableSelectionBar.Button>
</PopoverTrigger>
{/* We dont really use shadows much - but its needed here */}
<PopoverContent className="p-0 shadow-md" align="start" sideOffset={12}>
@@ -87,7 +87,9 @@ export function TeamListBulkAction({ table }: Props) {
<>
<Popover>
<PopoverTrigger asChild>
<DataTableSelectionBar.Button icon="users">{t("add_to_team")}</DataTableSelectionBar.Button>
<DataTableSelectionBar.Button icon="users" color="secondary">
{t("add_to_team")}
</DataTableSelectionBar.Button>
</PopoverTrigger>
{/* We dont really use shadows much - but its needed here */}
<PopoverContent className="w-[200px] p-0 shadow-md" align="start" sideOffset={12}>
@@ -579,7 +579,6 @@ function UserListTableContent() {
type="button"
color="primary"
StartIcon="plus"
className="rounded-md"
onClick={() =>
dispatch({
type: "INVITE_MEMBER",
@@ -604,8 +603,12 @@ function UserListTableContent() {
</DataTableSelectionBar.Root>
)}
{numberOfSelectedRows > 0 && (
<DataTableSelectionBar.Root className="justify-center">
<p className="text-brand-subtle px-2 text-center text-xs leading-none sm:text-sm sm:font-medium">
<DataTableSelectionBar.Root
className="justify-center"
style={{
width: "max-content",
}}>
<p className="text-brand-subtle shrink-0 px-2 text-center text-xs leading-none sm:text-sm sm:font-medium">
{t("number_selected", { count: numberOfSelectedRows })}
</p>
{!isPlatformUser ? (
@@ -613,6 +616,7 @@ function UserListTableContent() {
<TeamListBulkAction table={table} />
{numberOfSelectedRows >= 2 && (
<DataTableSelectionBar.Button
color="secondary"
onClick={() => setDynamicLinkVisible(!dynamicLinkVisible)}
icon="handshake">
{t("group_meeting")}
@@ -146,7 +146,7 @@ const WebhookForm = (props: {
<Form
form={formMethods}
handleSubmit={(values) => props.onSubmit({ ...values, changeSecret, newSecret })}>
<div className="border-subtle border-x p-6">
<div className="border-subtle rounded-t-lg border p-6">
<Controller
name="subscriberUrl"
control={formMethods.control}
@@ -199,6 +199,7 @@ const WebhookForm = (props: {
<>{t("event_triggers")}</>
</Label>
<Select
grow
options={translatedTriggerOptions}
isMulti
value={selectValue}
@@ -353,7 +354,7 @@ const WebhookForm = (props: {
</Button>
</SectionBottomActions>
<div className="mt-6 rounded-md">
<div className="mb-4 mt-6 rounded-md">
<WebhookTestDisclosure />
</div>
</Form>
@@ -65,18 +65,19 @@ export const usePlatformTabsNavigations = ({ formMethods, eventType, team, tabs
if (!requirePayment && tabs.includes("recurring")) {
navigation.splice(3, 0, {
name: "recurring",
name: t("recurring"),
onClick: () => setCurrentTab("recurring"),
isActive: currentTab === "recurring",
href: `${url}?tabName=recurring`,
icon: "repeat",
info: `recurring_event_tab_description`,
info: t(`recurring_event_tab_description`),
"data-testid": "recurring",
});
}
tabs.includes("availability") &&
navigation.splice(1, 0, {
name: "availability",
name: t("availability"),
onClick: () => setCurrentTab("availability"),
isActive: currentTab === "availability",
href: `${url}?tabName=availability`,
@@ -93,12 +94,13 @@ export const usePlatformTabsNavigations = ({ formMethods, eventType, team, tabs
}`
: formMethods.getValues("scheduleName") ?? `default_schedule_name`
: formMethods.getValues("scheduleName") ?? `default_schedule_name`,
"data-testid": "availability",
});
// If there is a team put this navigation item within the tabs
if (team && tabs.includes("team")) {
navigation.splice(2, 0, {
name: "assignment",
name: t("assignment"),
onClick: () => setCurrentTab("team"),
isActive: currentTab === "team",
href: `${url}?tabName=team`,
@@ -106,6 +108,7 @@ export const usePlatformTabsNavigations = ({ formMethods, eventType, team, tabs
info: `${t(watchSchedulingType?.toLowerCase() ?? "")}${
isManagedEventType ? ` - ${t("number_member", { count: watchChildrenCount || 0 })}` : ""
}`,
"data-testid": "assignment",
});
}
@@ -146,40 +149,44 @@ function getNavigation({ length, multipleDuration, t, tabs, url, onClick, curren
const tabsNavigation: VerticalTabItemProps[] = [];
tabs.includes("setup") &&
tabsNavigation.push({
name: "event_setup_tab_title",
name: t("event_setup_tab_title"),
onClick: () => onClick("setup"),
isActive: currentTab === "setup",
href: `${url}?tabName=setup`,
icon: "link",
info: `${duration} ${t("minute_timeUnit")}`, // TODO: Get this from props
"data-testid": `event_setup_tab_title`,
});
tabs.includes("limits") &&
tabsNavigation.push({
name: "event_limit_tab_title",
name: t("event_limit_tab_title"),
onClick: () => onClick("limits"),
isActive: currentTab === "limits",
href: `${url}?tabName=limits`,
icon: "clock",
info: `event_limit_tab_description`,
info: t(`event_limit_tab_description`),
"data-testid": "event_limit_tab_title",
});
tabs.includes("advanced") &&
tabsNavigation.push({
name: "event_advanced_tab_title",
name: t("event_advanced_tab_title"),
onClick: () => onClick("advanced"),
isActive: currentTab === "advanced",
href: `${url}?tabName=advanced`,
icon: "sliders-vertical",
info: `event_advanced_tab_description`,
info: t(`event_advanced_tab_description`),
"data-testid": "event_advanced_tab_title",
});
tabs.includes("payments") &&
tabsNavigation.push({
name: "event_payments_tab_title",
name: t("event_payments_tab_title"),
onClick: () => onClick("payments"),
isActive: currentTab === "payments",
href: `${url}?tabName=payments`,
icon: "credit-card",
info: `event_payments_tab_description`,
info: t(`event_payments_tab_description`),
"data-testid": "event_payments_tab_title",
});
return tabsNavigation;
@@ -83,56 +83,61 @@ export const useTabsNavigations = ({
if (!requirePayment) {
navigation.splice(3, 0, {
name: "recurring",
name: t("recurring"),
href: `/event-types/${formMethods.getValues("id")}?tabName=recurring`,
icon: "repeat",
info: `recurring_event_tab_description`,
info: t(`recurring_event_tab_description`),
"data-testid": "recurring",
});
}
navigation.splice(1, 0, {
name: "availability",
name: t("availability"),
href: `/event-types/${formMethods.getValues("id")}?tabName=availability`,
icon: "calendar",
info:
isManagedEventType || isChildrenManagedEventType
? formMethods.getValues("schedule") === null
? "members_default_schedule"
? t("members_default_schedule")
: isChildrenManagedEventType
? `${
formMethods.getValues("scheduleName")
? `${formMethods.getValues("scheduleName")} - ${t("managed")}`
: `default_schedule_name`
: t(`default_schedule_name`)
}`
: formMethods.getValues("scheduleName") ?? `default_schedule_name`
: formMethods.getValues("scheduleName") ?? `default_schedule_name`,
: formMethods.getValues("scheduleName") ?? t(`default_schedule_name`)
: formMethods.getValues("scheduleName") ?? t(`default_schedule_name`),
"data-testid": "availability",
});
// If there is a team put this navigation item within the tabs
if (team) {
navigation.splice(2, 0, {
name: "assignment",
name: t("assignment"),
href: `/event-types/${formMethods.getValues("id")}?tabName=team`,
icon: "users",
info: `${t(watchSchedulingType?.toLowerCase() ?? "")}${
isManagedEventType ? ` - ${t("number_member", { count: watchChildrenCount || 0 })}` : ""
}`,
"data-testid": "assignment",
});
}
const showInstant = !(isManagedEventType || isChildrenManagedEventType);
if (showInstant) {
if (team) {
navigation.push({
name: "instant_tab_title",
name: t("instant_tab_title"),
href: `/event-types/${eventType.id}?tabName=instant`,
icon: "phone-call",
info: `instant_event_tab_description`,
info: t(`instant_event_tab_description`),
"data-testid": "instant_tab_title",
});
}
}
navigation.push({
name: "webhooks",
name: t("webhooks"),
href: `/event-types/${formMethods.getValues("id")}?tabName=webhooks`,
icon: "webhook",
info: `${activeWebhooksNumber} ${t("active")}`,
"data-testid": "webhooks",
});
const hidden = true; // hidden while in alpha trial. you can access it with tabName=ai
if (team && hidden) {
@@ -140,7 +145,8 @@ export const useTabsNavigations = ({
name: "Cal.ai",
href: `/event-types/${eventType.id}?tabName=ai`,
icon: "sparkles",
info: "cal_ai_event_tab_description", // todo `cal_ai_event_tab_description`,
info: t("cal_ai_event_tab_description"), // todo `cal_ai_event_tab_description`,
"data-testid": "Cal.ai",
});
}
return navigation;
@@ -189,35 +195,40 @@ function getNavigation({
return [
{
name: "event_setup_tab_title",
name: t("event_setup_tab_title"),
href: `/event-types/${id}?tabName=setup`,
icon: "link",
info: `${duration} ${t("minute_timeUnit")}`, // TODO: Get this from props
"data-testid": `event_setup_tab_title`,
},
{
name: "event_limit_tab_title",
name: t("event_limit_tab_title"),
href: `/event-types/${id}?tabName=limits`,
icon: "clock",
info: `event_limit_tab_description`,
info: t(`event_limit_tab_description`),
"data-testid": "event_limit_tab_title",
},
{
name: "event_advanced_tab_title",
name: t("event_advanced_tab_title"),
href: `/event-types/${id}?tabName=advanced`,
icon: "sliders-vertical",
info: `event_advanced_tab_description`,
info: t(`event_advanced_tab_description`),
"data-testid": "event_advanced_tab_title",
},
{
name: "apps",
name: t("apps"),
href: `/event-types/${id}?tabName=apps`,
icon: "grid-3x3",
//TODO: Handle proper translation with count handling
info: `${installedAppsNumber} apps, ${enabledAppsNumber} ${t("active")}`,
"data-testid": "apps",
},
{
name: "workflows",
name: t("workflows"),
href: `/event-types/${id}?tabName=workflows`,
icon: "zap",
info: `${enabledWorkflowsNumber} ${t("active")}`,
"data-testid": "workflows",
},
] satisfies VerticalTabItemProps[];
}
File diff suppressed because it is too large. Load diff
+30 -35
View File
@@ -1,3 +1,4 @@
import { cva } from "class-variance-authority";
import classNames from "classnames";
import type { ReactNode } from "react";
import { forwardRef } from "react";
@@ -5,36 +6,36 @@ import { forwardRef } from "react";
import { Icon } from "../icon";
import type { IconName } from "../icon";
export const alertStyles = cva("rounded-[10px] p-3", {
variants: {
severity: {
neutral: "bg-default border-subtle border-[1px] text-default",
info: "bg-semantic-info-subtle text-semantic-info",
warning: "bg-semantic-attention-subtle text-semantic-attention",
error: "bg-semantic-error-subtle text-semantic-error",
},
},
defaultVariants: {
severity: "neutral",
},
});
export interface AlertProps {
title?: ReactNode;
// @TODO: Message should be children, more flexible?
message?: ReactNode;
// @TODO: Provide action buttons so style is always the same.
actions?: ReactNode;
className?: string;
iconClassName?: string;
// @TODO: Success and info shouldn't exist as per design?
severity: "success" | "warning" | "error" | "info" | "neutral" | "green";
severity: "warning" | "error" | "info" | "neutral";
CustomIcon?: IconName;
customIconColor?: string;
}
export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
const { severity, iconClassName, CustomIcon, customIconColor } = props;
return (
<div
data-testid="alert"
ref={ref}
className={classNames(
"rounded-md p-3",
props.className,
severity === "error" && "bg-red-100 text-red-900 dark:bg-red-900 dark:text-red-200",
severity === "warning" && "text-attention bg-attention dark:bg-orange-900 dark:text-orange-200",
severity === "info" && "bg-blue-100 text-blue-900 dark:bg-blue-900 dark:text-blue-200",
severity === "green" && "bg-success text-success",
severity === "success" && "bg-inverted text-inverted",
severity === "neutral" && "bg-subtle text-default"
)}>
<div data-testid="alert" ref={ref} className={alertStyles({ severity, className: props.className })}>
<div className="relative flex md:flex-row">
{CustomIcon ? (
<div className="flex-shrink-0">
@@ -42,16 +43,16 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
name={CustomIcon}
data-testid="custom-icon"
aria-hidden="true"
className={classNames(`h-5 w-5`, iconClassName, customIconColor ?? "text-default")}
className={classNames(`h4 mr-2 w-4`, iconClassName, customIconColor ?? "text-default")}
/>
</div>
) : (
<div className="flex-shrink-0">
<div className={classNames("mr-2 flex-shrink-0", props.title ? "" : "mt-0.5")}>
{severity === "error" && (
<Icon
name="circle-x"
data-testid="circle-x"
className={classNames("h-5 w-5 text-red-900 dark:text-red-200", iconClassName)}
className={classNames("h4 w-4", iconClassName)}
aria-hidden="true"
/>
)}
@@ -59,7 +60,7 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
<Icon
name="triangle-alert"
data-testid="alert-triangle"
className={classNames("text-attention h-5 w-5 dark:text-orange-200", iconClassName)}
className={classNames("h4 w-4", iconClassName)}
aria-hidden="true"
/>
)}
@@ -67,7 +68,7 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
<Icon
name="info"
data-testid="info"
className={classNames("h-5 w-5 text-blue-900 dark:text-blue-200", iconClassName)}
className={classNames("h4 w-4", iconClassName)}
aria-hidden="true"
/>
)}
@@ -75,26 +76,20 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
<Icon
name="info"
data-testid="neutral"
className={classNames("text-default h-5 w-5 fill-transparent", iconClassName)}
aria-hidden="true"
/>
)}
{severity === "success" && (
<Icon
name="circle-check"
data-testid="circle-check"
className={classNames("fill-muted text-default h-5 w-5", iconClassName)}
className={classNames("text-default h4 w-4 fill-transparent", iconClassName)}
aria-hidden="true"
/>
)}
</div>
)}
<div className="flex flex-grow flex-col sm:flex-row">
<div className="ltr:ml-3 rtl:mr-3">
<h3 className="text-sm font-medium">{props.title}</h3>
<div className="text-sm">{props.message}</div>
<div className="space-y-1 ltr:ml-3 rtl:mr-3">
{props.title && <h3 className="text-sm font-medium leading-none">{props.title}</h3>}
{props.message && <div className="text-sm leading-5">{props.message}</div>}
</div>
{props.actions && <div className="ml-auto mt-2 text-sm sm:mt-0 md:relative">{props.actions}</div>}
{props.actions && (
<div className="ml-auto mt-auto text-sm sm:mt-0 md:relative">{props.actions}</div>
)}
</div>
</div>
</div>
@@ -33,9 +33,4 @@ describe("Tests for Alert component", () => {
render(<Alert severity="neutral" />);
expect(await screen.findByTestId("neutral")).toBeInTheDocument();
});
test("Should render corresponding icon: success", async () => {
render(<Alert severity="success" />);
expect(await screen.findByTestId("circle-check")).toBeInTheDocument();
});
});
+49 -16
View File
@@ -1,5 +1,6 @@
import * as AvatarPrimitive from "@radix-ui/react-avatar";
import { Provider as TooltipPrimitiveProvider } from "@radix-ui/react-tooltip";
import { cva } from "class-variance-authority";
import Link from "next/link";
import classNames from "@calcom/lib/classNames";
@@ -11,7 +12,8 @@ type Maybe<T> = T | null | undefined;
export type AvatarProps = {
className?: string;
size?: "xxs" | "xs" | "xsm" | "sm" | "md" | "mdLg" | "lg" | "xl";
size?: "xs" | "xsm" | "sm" | "md" | "mdLg" | "lg" | "xl";
shape?: "circle" | "square";
imageSrc?: Maybe<string>;
title?: string;
alt: string;
@@ -23,34 +25,65 @@ export type AvatarProps = {
"data-testid"?: string;
};
const sizesPropsBySize = {
xxs: "w-3.5 h-3.5 min-w-3.5 min-h-3.5", // 14px
xs: "w-4 h-4 min-w-4 min-h-4 max-h-4", // 16px
xsm: "w-5 h-5 min-w-5 min-h-5", // 20px
sm: "w-6 h-6 min-w-6 min-h-6", // 24px
md: "w-8 h-8 min-w-8 min-h-8", // 32px
mdLg: "w-10 h-10 min-w-10 min-h-10", //40px
lg: "w-16 h-16 min-w-16 min-h-16", // 64px
xl: "w-24 h-24 min-w-24 min-h-24", // 96px
} as const;
const avatarClasses = cva(
"bg-emphasis border-default relative inline-flex aspect-square items-center justify-center border align-top",
{
variants: {
size: {
xs: "w-4 h-4 min-w-4 min-h-4 max-h-4", // 16px
xsm: "w-5 h-5 min-w-5 min-h-5", // 20px
sm: "w-6 h-6 min-w-6 min-h-6", // 24px
md: "w-8 h-8 min-w-8 min-h-8", // 32px
mdLg: "w-10 h-10 min-w-10 min-h-10", // 40px
lg: "w-16 h-16 min-w-16 min-h-16", // 64px
xl: "w-24 h-24 min-w-24 min-h-24", // 96px
},
shape: {
circle: "rounded-full",
square: "",
},
},
defaultVariants: {
size: "md",
shape: "circle",
},
compoundVariants: [
{
size: ["xs", "xsm", "sm"],
shape: "square",
className: "rounded",
},
{
size: ["md"],
shape: "square",
className: "rounded-md",
},
{
size: ["mdLg", "lg", "xl"],
shape: "square",
className: "rounded-[10px]",
},
],
}
);
export function Avatar(props: AvatarProps) {
const { imageSrc, size = "md", alt, title, href, indicator } = props;
const rootClass = classNames("aspect-square rounded-full", sizesPropsBySize[size]);
const avatarClass = avatarClasses({ size, shape: props.shape });
const rootClass = classNames("aspect-square rounded-full", avatarClass);
let avatar = (
<AvatarPrimitive.Root
data-testid={props?.["data-testid"]}
className={classNames(
"bg-emphasis item-center relative inline-flex aspect-square justify-center rounded-full align-top",
avatarClass,
indicator ? "overflow-visible" : "overflow-hidden",
props.className,
sizesPropsBySize[size]
props.className
)}>
<>
<AvatarPrimitive.Image
src={imageSrc ?? undefined}
alt={alt}
className={classNames("aspect-square rounded-full", sizesPropsBySize[size])}
className={classNames("aspect-square", avatarClass)}
/>
<AvatarPrimitive.Fallback
delayMs={600}
+4 -3
View File
@@ -20,11 +20,12 @@ export const badgeStyles = cva("font-medium inline-flex items-center justify-cen
red: "bg-error text-error",
error: "bg-error text-error",
grayWithoutHover: "bg-gray-100 text-gray-800 dark:bg-darkgray-200 dark:text-darkgray-800",
purple: "bg-purple-50 text-purple-800",
},
size: {
sm: "px-1 py-0.5 text-xs leading-3",
md: "py-1 px-1.5 text-xs leading-3",
lg: "py-1 px-2 text-sm leading-4",
sm: "px-1 py-1 text-[10px] leading-none",
md: "py-1 px-1.5 text-xs leading-none",
lg: "py-1 px-1.5 text-sm leading-none rounded-lg",
},
},
defaultVariants: {
+53 -58
View File
@@ -1,12 +1,10 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable playwright/missing-playwright-await */
import { render, screen, fireEvent } from "@testing-library/react";
import { vi } from "vitest";
import { Icon } from "../icon";
import { Badge, badgeStyles } from "./Badge";
describe("Tests for Badge component", () => {
describe("Badge", () => {
const variants = [
"default",
"warning",
@@ -18,74 +16,71 @@ describe("Tests for Badge component", () => {
"red",
"error",
"grayWithoutHover",
];
"purple",
] as const;
const sizes = ["sm", "md", "lg"];
const children = "Test Badge";
test.each(variants)("Should apply variant class", (variant) => {
render(<Badge variant={variant as any}>{children}</Badge>);
const badgeClass = screen.getByText(children).className;
const badgeComponentClass = badgeStyles({ variant: variant as any });
expect(badgeClass).toEqual(badgeComponentClass);
});
test.each(sizes)("Should apply size class", (size) => {
render(<Badge size={size as any}>{children}</Badge>);
const badgeClass = screen.getByText(children).className;
const badgeComponentClass = badgeStyles({ size: size as any });
expect(badgeClass).toEqual(badgeComponentClass);
});
test("Should render without errors", () => {
render(<Badge>{children}</Badge>);
expect(screen.getByText(children)).toBeInTheDocument();
});
test("Should render WithDot if the prop is true and shouldn't render if is false", async () => {
const { rerender } = render(<Badge withDot>{children}</Badge>);
expect(await screen.findByTestId("go-primitive-dot")).toBeInTheDocument();
rerender(<Badge>{children}</Badge>);
expect(screen.queryByTestId("go-primitive-dot")).not.toBeInTheDocument();
});
test("Should render with a startIcon when startIcon prop is provided shouldn't render if is false", () => {
const { rerender } = render(<Badge customStartIcon={<svg data-testid="start-icon" />}>{children}</Badge>);
expect(screen.getByTestId("start-icon")).toBeInTheDocument();
rerender(<Badge>{children}</Badge>);
expect(screen.queryByTestId("start-icon")).not.toBeInTheDocument();
});
test("Should render as a button when onClick prop is provided and shouldn't if is not", () => {
const handleClick = vi.fn();
const { rerender } = render(<Badge onClick={handleClick}>{children}</Badge>);
test.each(variants)("renders %s variant correctly", (variant) => {
render(<Badge variant={variant}>{children}</Badge>);
const badge = screen.getByText(children);
expect(badge.tagName).toBe("BUTTON");
fireEvent.click(badge);
expect(handleClick).toHaveBeenCalledTimes(1);
rerender(<Badge>{children}</Badge>);
const updateBadge = screen.getByText(children);
expect(updateBadge.tagName).not.toBe("BUTTON");
expect(badge.className).toContain(badgeStyles({ variant }));
});
test("Should render as a div when onClick prop is not provided", () => {
test("renders with default props", () => {
render(<Badge>{children}</Badge>);
const badge = screen.getByText(children);
expect(badge).toBeInTheDocument();
expect(badge.tagName).toBe("DIV");
});
test("Should render children when provided", () => {
const { getByText } = render(
test("renders with dot when withDot prop is true", () => {
render(<Badge withDot>{children}</Badge>);
expect(screen.getByTestId("go-primitive-dot")).toBeInTheDocument();
});
test("renders with startIcon when provided", () => {
render(<Badge startIcon="info">{children}</Badge>);
expect(screen.getByTestId("start-icon")).toBeInTheDocument();
});
test("renders with customStartIcon when provided", () => {
render(<Badge customStartIcon={<Icon name="info" data-testid="custom-icon" />}>{children}</Badge>);
expect(screen.getByTestId("custom-icon")).toBeInTheDocument();
});
test("renders as button with onClick handler", () => {
const handleClick = vi.fn();
render(<Badge onClick={handleClick}>{children}</Badge>);
const badge = screen.getByText(children);
expect(badge.tagName).toBe("BUTTON");
fireEvent.click(badge);
expect(handleClick).toHaveBeenCalledTimes(1);
});
test("renders with rounded style when rounded prop is true", () => {
render(<Badge rounded>{children}</Badge>);
const badge = screen.getByText(children);
expect(badge.className).toContain("h-5 w-5 rounded-full p-0");
});
test("renders with additional className when provided", () => {
const customClass = "custom-class";
render(<Badge className={customClass}>{children}</Badge>);
const badge = screen.getByText(children);
expect(badge.className).toContain(customClass);
});
test("renders nested children correctly", () => {
render(
<Badge>
<span>Child element 1</span>
<span>Child element 2</span>
<span data-testid="child-1">Child 1</span>
<span data-testid="child-2">Child 2</span>
</Badge>
);
expect(getByText("Child element 1")).toBeInTheDocument();
expect(getByText("Child element 2")).toBeInTheDocument();
expect(screen.getByTestId("child-1")).toBeInTheDocument();
expect(screen.getByTestId("child-2")).toBeInTheDocument();
});
});
+134 -24
View File
@@ -40,28 +40,118 @@ export type ButtonProps = ButtonBaseProps &
);
export const buttonClasses = cva(
"whitespace-nowrap inline-flex items-center text-sm font-medium relative rounded-md transition disabled:cursor-not-allowed",
"group whitespace-nowrap inline-flex items-center text-sm font-medium relative rounded-[10px] transition disabled:cursor-not-allowed gap-1",
{
variants: {
variant: {
button: "",
icon: "flex justify-center",
fab: "rounded-full justify-center md:rounded-md radix-state-open:rotate-45 md:radix-state-open:rotate-0 radix-state-open:shadown-none radix-state-open:ring-0 !shadow-none",
fab: "rounded-full justify-center md:rounded-[10px] radix-state-open:rotate-45 md:radix-state-open:rotate-0 radix-state-open:shadown-none radix-state-open:ring-0",
},
color: {
primary:
"bg-brand-default hover:bg-brand-emphasis focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset focus-visible:ring-brand-default text-brand disabled:bg-brand-subtle disabled:text-brand-subtle disabled:opacity-40 disabled:hover:bg-brand-subtle disabled:hover:text-brand-default disabled:hover:opacity-40",
secondary:
"text-emphasis border border-default bg-default hover:bg-muted hover:border-emphasis focus-visible:bg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset focus-visible:ring-empthasis disabled:border-subtle disabled:bg-opacity-30 disabled:text-muted disabled:hover:bg-opacity-30 disabled:hover:text-muted disabled:hover:border-subtle disabled:hover:bg-default",
minimal:
"text-emphasis hover:bg-subtle focus-visible:bg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset focus-visible:ring-empthasis disabled:border-subtle disabled:bg-opacity-30 disabled:text-muted disabled:hover:bg-transparent disabled:hover:text-muted disabled:hover:border-subtle",
destructive:
"border border-default text-emphasis hover:text-red-700 dark:hover:text-red-100 focus-visible:text-red-700 hover:border-red-100 focus-visible:border-red-100 hover:bg-error focus-visible:bg-error focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset focus-visible:ring-red-700 disabled:bg-red-100 disabled:border-red-200 disabled:text-red-700 disabled:hover:border-red-200 disabled:opacity-40",
primary: [
// Base colors
"bg-brand-default",
"text-brand",
// Focus state
"focus-visible:outline-none",
"focus-visible:ring-0",
"focus-visible:shadow-button-solid-brand-focused",
// Border
"border border-brand-default",
// Disabled
"disabled:opacity-30",
// Shadows and effects
"shadow-button-solid-brand-default",
"enabled:active:shadow-button-solid-brand-active",
"enabled:hover:shadow-button-solid-brand-hover",
"transition-shadow",
"transition-transform",
"duration-100",
],
secondary: [
// Base colors and border
"bg-default",
"text-default",
"border",
"border-default",
// Hover state
"enabled:hover:bg-muted",
"enabled:hover:border-emphasis",
"enabled:hover:text-emphasis",
// Disabled
"disabled:opacity-30",
// Focus state
"focus-visible:bg-subtle",
"focus-visible:outline-none",
"focus-visible:ring-0",
"focus-visible:shadow-outline-gray-focused",
// Shadows and effects
"shadow-outline-gray-rested",
"enabled:hover:shadow-outline-gray-hover",
"enabled:active:shadow-outline-gray-active",
"transition-shadow",
"duration-200",
],
minimal: [
// Base color
"text-subtle",
"border border-transparent",
// Hover
"enabled:hover:bg-subtle",
"enabled:hover:text-emphasis",
"enabled:hover:border-subtle hover:border",
// Disabled
"disabled:opacity-30",
// Focus
"focus-visible:bg-subtle",
"focus-visible:outline-none",
"focus-visible:ring-0",
"focus-visible:border-subtle",
"focus-visible:shadow-button-outline-gray-focused",
// Shadows and effects
"enabled:active:shadow-outline-gray-active",
"transition-shadow",
"duration-200",
],
destructive: [
// Base colors and border
"border",
"border-default",
"text-error",
// Hover state
"dark:hover:text-red-100",
"hover:border-semantic-danager-subtle",
"hover:bg-error",
// Focus state
"focus-visible:text-red-700",
"focus-visible:bg-error",
"focus-visible:outline-none",
"focus-visible:ring-0",
"focus-visible:shadow-button-outline-red-focused",
// Disabled state
"disabled:bg-red-100",
"disabled:border-red-200",
"disabled:text-red-700",
"disabled:hover:border-red-200",
"disabled:opacity-30",
// Shadows and effects
"shadow-outline-red-rested",
"enabled:hover:shadow-outline-red-hover",
"enabled:active:shadow-outline-red-active",
"transition-shadow",
"duration-200",
],
},
size: {
sm: "px-3 py-2 leading-4 rounded-md" /** For backwards compatibility */,
base: "h-9 px-4 py-2.5 ",
lg: "h-[36px] px-4 py-2.5 ",
xs: "h-6 p-2 leading-none text-xs rounded-md",
sm: "h-7 px-2 py-1.5 leading-none text-sm" /** For backwards compatibility */,
base: "px-2.5 py-2 text-sm leading-none",
lg: "px-3 py-2.5 ",
},
loading: {
true: "cursor-wait",
@@ -72,7 +162,7 @@ export const buttonClasses = cva(
{
loading: true,
color: "primary",
className: "bg-brand-subtle text-brand-subtle",
className: "opacity-30",
},
// Secondary variants
{
@@ -98,15 +188,25 @@ export const buttonClasses = cva(
size: "base",
className: "min-h-[36px] min-w-[36px] !p-2 hover:border-default",
},
{
variant: "icon",
size: "xs",
className: "h-5 w-5 !p-1 rounded-md",
},
{
variant: "icon",
size: "sm",
className: "h-6 w-6 !p-1",
className: "h-6 w-6 !p-1 rounded-md",
},
{
variant: "icon",
size: "lg",
className: "h-10 w-10 !p-1",
},
{
variant: "fab",
size: "base",
className: "h-14 md:h-9 md:w-auto md:px-4 md:py-2.5",
className: "min-h-14 md:min-h-9 md:min-w-auto md:px-4 md:py-2.5",
},
],
defaultVariants: {
@@ -163,24 +263,31 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
<>
{variant === "fab" ? (
<>
<Icon
name={StartIcon}
className="hidden h-4 w-4 stroke-[1.5px] ltr:-ml-1 ltr:mr-2 rtl:-mr-1 rtl:ml-2 md:inline-flex"
/>
<Icon name={StartIcon} className="hidden h-4 w-4 stroke-[1.5px] md:inline-flex" />
<Icon name="plus" data-testid="plus" className="inline h-6 w-6 md:hidden" />
</>
) : (
<Icon
data-name="start-icon"
name={StartIcon}
className={classNames(
loading ? "invisible" : "visible",
"button-icon group-active:translate-y-[0.5px]",
variant === "icon" && "h-4 w-4",
variant === "button" && "h-4 w-4 stroke-[1.5px] ltr:-ml-1 ltr:mr-2 rtl:-mr-1 rtl:ml-2"
variant === "button" && "h-4 w-4 stroke-[1.5px] "
)}
/>
)}
</>
))}
{variant === "fab" ? <span className="hidden md:inline">{props.children}</span> : props.children}
{props.children &&
(variant === "fab" ? (
<span className={`hidden md:inline ${loading ? "invisible" : "visible "}`}>{props.children}</span>
) : (
<span className={loading ? "invisible" : "visible group-active:translate-y-[0.5px]"}>
{props.children}
</span>
))}
{loading && (
<div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform">
<svg
@@ -211,9 +318,10 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
<Icon
name={EndIcon}
className={classNames(
"inline-flex",
loading ? "invisible" : "visible",
"group-active:translate-y-[0.5px]",
variant === "icon" && "h-4 w-4",
variant === "button" && "h-4 w-4 stroke-[1.5px] ltr:-mr-1 ltr:ml-2 rtl:-ml-1 rtl:mr-2"
variant === "button" && "h-4 w-4 stroke-[1.5px] "
)}
/>
)}
@@ -266,3 +374,5 @@ const Wrapper = ({
</Tooltip>
);
};
Button.displayName = "Button";
@@ -0,0 +1,76 @@
"use client";
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
import type { ReactNode } from "react";
import { forwardRef } from "react";
import { Icon } from "../icon";
import type { ButtonBaseProps, ButtonProps } from "./Button";
import { Button, buttonClasses } from "./Button";
export interface SplitButtonProps extends ButtonBaseProps {
children?: ReactNode;
dropdown?: {
items: {
label: string;
action: () => void;
icon?: ButtonProps["StartIcon"];
color?: ButtonProps["color"];
}[];
};
}
export const SplitButton = forwardRef<HTMLButtonElement, SplitButtonProps>(function SplitButton(
{ children, dropdown, StartIcon, color = "primary", ...mainButtonProps },
forwardedRef
) {
if (!dropdown) {
return (
<Button ref={forwardedRef} StartIcon={StartIcon} color={color} {...mainButtonProps}>
{children}
</Button>
);
}
return (
<div className="inline-flex">
<Button
{...mainButtonProps}
className="rounded-r-none border-r-0"
StartIcon={StartIcon}
color={color}
ref={forwardedRef}>
{children}
</Button>
<DropdownMenuPrimitive.Root>
<DropdownMenuPrimitive.Trigger asChild>
<button
className={buttonClasses({
variant: "button",
color,
size: mainButtonProps.size,
className: "rounded-l-none px-2",
})}>
<Icon name="chevron-down" className="h-4 w-4" />
</button>
</DropdownMenuPrimitive.Trigger>
<DropdownMenuPrimitive.Portal>
<DropdownMenuPrimitive.Content
align="end"
className="bg-default border-subtle z-50 mt-1 min-w-[180px] overflow-hidden rounded-md border p-1 shadow-md">
{dropdown.items.map((item, index) => (
<DropdownMenuPrimitive.Item
key={index}
className="text-default hover:bg-subtle focus:bg-subtle flex w-full cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm outline-none"
onClick={item.action}>
{item.icon && <Icon name={item.icon} className="h-4 w-4" />}
{item.label}
</DropdownMenuPrimitive.Item>
))}
</DropdownMenuPrimitive.Content>
</DropdownMenuPrimitive.Portal>
</DropdownMenuPrimitive.Root>
</div>
);
});
+1
View File
@@ -1,3 +1,4 @@
export { Button, buttonClasses } from "./Button";
export { SplitButton } from "./SplitButton";
export type { ButtonBaseProps, ButtonProps, ButtonColor } from "./Button";
export { default as LinkIconButton } from "./LinkIconButton";
@@ -4,24 +4,30 @@ import classNames from "@calcom/lib/classNames";
type Props = { children: React.ReactNode; combined?: boolean; containerProps?: JSX.IntrinsicElements["div"] };
/**
* Breakdown of Tailwind Magic below
* [&_button]:border-l-0 [&_a]:border-l-0 -> Selects all buttons/a tags and applies a border left of 0
* [&>*:first-child]:rounded-l-md [&>*:first-child]:border-l -> Selects the first child of the content
* ounds the left side
* [&>*:last-child]:rounded-r-md -> Selects the last child of the content and rounds the right side
* We dont need to add border to the right as we never remove it
*/
const sizeToRadius = {
lg: "12px",
base: "8px",
sm: "10px",
xs: "8px",
} as const;
export function ButtonGroup({ children, combined = false, containerProps }: Props) {
// Get the size from the first button child if it exists
const firstButton = React.Children.toArray(children)[0] as React.ReactElement;
const size = firstButton?.props?.size || "base";
const radius = sizeToRadius[size as keyof typeof sizeToRadius];
const style = combined ? ({ "--btn-group-radius": radius } as React.CSSProperties) : undefined;
return (
<div
{...containerProps}
style={style}
className={classNames(
"flex",
!combined
? "space-x-2 rtl:space-x-reverse"
: "ltr:[&>*:first-child]:ml-0 ltr:[&>*:first-child]:rounded-l-md ltr:[&>*:first-child]:border-l rtl:[&>*:first-child]:rounded-r-md rtl:[&>*:first-child]:border-r ltr:[&>*:last-child]:rounded-r-md rtl:[&>*:last-child]:rounded-l-md [&>a]:-ml-[1px] hover:[&>a]:z-[1] [&>button]:-ml-[1px] hover:[&>button]:z-[1] [&_a]:rounded-none [&_button]:rounded-none",
: "[&>*:first-child]:rounded-l-[var(--btn-group-radius)] rtl:[&>*:first-child]:rounded-l-none rtl:[&>*:first-child]:rounded-r-[var(--btn-group-radius)] [&>*:last-child]:rounded-r-[var(--btn-group-radius)] rtl:[&>*:last-child]:rounded-l-[var(--btn-group-radius)] rtl:[&>*:last-child]:rounded-r-none [&>*:not(:first-child)]:-ml-[1px] [&>*]:rounded-none [&>*]:border hover:[&>*]:z-[1]",
containerProps?.className
)}>
{children}
+1 -3
View File
@@ -1,8 +1,6 @@
const StepCard: React.FC<{ children: React.ReactNode }> = (props) => {
return (
<div className="sm:border-subtle bg-default mt-10 border p-4 dark:bg-black sm:rounded-md sm:p-8">
{props.children}
</div>
<div className="sm:border-subtle bg-muted mt-10 border p-4 sm:rounded-md sm:p-8">{props.children}</div>
);
};
@@ -1,3 +1,5 @@
"use client";
import { usePathname, useRouter } from "next/navigation";
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
@@ -77,6 +79,7 @@ export function CreateButton(props: CreateBtnProps) {
<>
{!hasTeams && !platform ? (
<Button
size="sm"
onClick={() =>
!!CreateDialog
? openModal(options[0])
@@ -97,6 +100,7 @@ export function CreateButton(props: CreateBtnProps) {
<Button
variant={disableMobileButton ? "button" : "fab"}
StartIcon="plus"
size="sm"
data-testid="create-button-dropdown"
loading={isPending}
{...restProps}>
+42 -28
View File
@@ -1,12 +1,13 @@
"use client";
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { cva, type VariantProps } from "class-variance-authority";
import { usePathname, useRouter } from "next/navigation";
import type { ForwardRefExoticComponent, ReactElement, ReactNode } from "react";
import React, { useMemo, useState } from "react";
import { Dialog as PlatformDialogPrimitives, useIsPlatform } from "@calcom/atoms/monorepo";
import classNames from "@calcom/lib/classNames";
import { classNames } from "@calcom/lib";
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
import { useLocale } from "@calcom/lib/hooks/useLocale";
@@ -15,6 +16,23 @@ import { Button } from "../button";
import type { IconName } from "../icon";
import { Icon } from "../icon";
const dialogClasses = cva(
"fadeIn bg-default scroll-bar fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 rounded-2xl text-left shadow-xl focus-visible:outline-none sm:align-middle",
{
variants: {
size: {
xl: "px-8 pt-8 sm:max-w-[90rem]",
lg: "px-8 pt-8 sm:max-w-[70rem]",
md: "px-8 pt-8 sm:max-w-[48rem]",
default: "px-8 pt-8 sm:max-w-[35rem]",
},
},
defaultVariants: {
size: "default",
},
}
);
export type DialogProps = React.ComponentProps<(typeof DialogPrimitive)["Root"]> & {
name?: string;
clearQueryParamsOnClose?: string[];
@@ -81,7 +99,6 @@ function WebDialog(props: DialogProps) {
}
type DialogContentProps = React.ComponentProps<(typeof DialogPrimitive)["Content"]> & {
size?: "xl" | "lg" | "md";
type?: "creation" | "confirmation";
title?: string;
description?: string | JSX.Element | null;
@@ -94,7 +111,7 @@ type DialogContentProps = React.ComponentProps<(typeof DialogPrimitive)["Content
* Disables the ability to close the dialog by clicking outside of it. Could be useful when the dialog is doing something critical which might be in progress.
*/
preventCloseOnOutsideClick?: boolean;
};
} & VariantProps<typeof dialogClasses>;
// enableOverflow:- use this prop whenever content inside DialogContent could overflow and require scrollbar
export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
@@ -126,9 +143,9 @@ export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps
return (
<Portal>
{forceOverlayWhenNoModal ? (
<div className="fadeIn fixed inset-0 z-50 bg-neutral-800 bg-opacity-70 transition-opacity dark:bg-opacity-70 " />
<div className="fadeIn fixed inset-0 z-50 bg-neutral-800 bg-opacity-70 transition-opacity" />
) : (
<Overlay className="fadeIn fixed inset-0 z-50 bg-neutral-800 bg-opacity-70 transition-opacity dark:bg-opacity-70 " />
<Overlay className="fadeIn fixed inset-0 z-50 bg-neutral-800 bg-opacity-70 transition-opacity dark:bg-opacity-80" />
)}
<Content
{...props}
@@ -138,16 +155,9 @@ export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps
}
}}
className={classNames(
"fadeIn bg-default scroll-bar fixed left-1/2 top-1/2 z-50 w-full max-w-[22rem] -translate-x-1/2 -translate-y-1/2 rounded-md text-left shadow-xl focus-visible:outline-none sm:align-middle",
props.size == "xl"
? "px-8 pt-8 sm:max-w-[90rem]"
: props.size == "lg"
? "px-8 pt-8 sm:max-w-[70rem]"
: props.size == "md"
? "px-8 pt-8 sm:max-w-[48rem]"
: "px-8 pt-8 sm:max-w-[35rem]",
dialogClasses({ size: props.size }),
"max-h-[95vh]",
enableOverflow ? "overflow-auto" : "overflow-visible",
enableOverflow ? "overflow-y-auto" : "overflow-visible",
`${props.className || ""}`
)}
ref={forwardedRef}>
@@ -191,11 +201,15 @@ export function DialogHeader(props: DialogHeaderProps) {
<div className="mb-4">
<h3
data-testid="dialog-title"
className="leading-20 text-semibold font-cal text-emphasis pb-1 text-xl"
className="leading-20 text-semibold text-emphasis font-cal mb-1 text-xl"
id="modal-title">
{props.title}
</h3>
{props.subtitle && <p className="text-subtle text-sm">{props.subtitle}</p>}
{props.subtitle && (
<p className="text-subtle text-sm leading-none" data-testid="dialog-subtitle">
{props.subtitle}
</p>
)}
</div>
);
}
@@ -208,16 +222,14 @@ type DialogFooterProps = {
export function DialogFooter(props: DialogFooterProps) {
return (
<div className={classNames("bg-default bottom-0", props?.noSticky ? "" : "sticky", props.className)}>
{props.showDivider && (
// TODO: the -mx-8 is causing overflow in the dialog buttons
<hr data-testid="divider" className="border-subtle -mx-8" />
)}
<div
className={classNames(
"flex justify-end space-x-2 pb-4 pt-4 rtl:space-x-reverse",
!props.showDivider && "pb-8"
)}>
<div
className={classNames(
"bg-muted border-subtle bottom-0 -mx-8 mt-10 rounded-b-2xl",
props?.noSticky ? "" : "sticky",
props.className
)}>
{props.showDivider && <div data-testid="divider" className="border-subtle border-t" />}
<div className={classNames("flex justify-end space-x-2 px-8 py-4 font-sans rtl:space-x-reverse")}>
{props.children}
</div>
</div>
@@ -265,13 +277,15 @@ export function DialogClose(
[isPlatform]
);
const { className, ...buttonProps } = props;
return (
<Close asChild {...props.dialogCloseProps}>
{/* This will require the i18n string passed in */}
<Button
data-testid={props["data-testid"] || "dialog-rejection"}
color={props.color || "minimal"}
{...props}>
className={classNames(props.color === "destructive" && "destructive", className)}
{...buttonProps}>
{props.children ? props.children : t("close")}
</Button>
</Close>
+84 -94
View File
@@ -1,7 +1,7 @@
import { render, screen } from "@testing-library/react";
import { render, screen, fireEvent } from "@testing-library/react";
import { vi } from "vitest";
import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader } from "./Dialog";
import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTrigger } from "./Dialog";
vi.mock("@calcom/lib/hooks/useCompatSearchParams", () => ({
useCompatSearchParams() {
@@ -25,116 +25,106 @@ vi.mock("next/navigation", () => ({
},
}));
const title = "Dialog Header";
const subtitle = "Dialog Subtitle";
describe("Dialog", () => {
const title = "Dialog Title";
const subtitle = "Dialog Subtitle";
const content = "Dialog Content";
const footerContent = "Dialog Footer";
const DialogComponent = (props: {
open: boolean;
title?: string;
subtitle?: string;
type?: "creation" | "confirmation";
showDivider?: boolean;
color?: "primary" | "secondary" | "minimal" | "destructive";
}) => {
return (
<Dialog open={props.open}>
<DialogContent type={props.type}>
<div className="flex flex-row justify-center align-middle ">
const TestDialog = (props: {
open?: boolean;
title?: string;
subtitle?: string;
type?: "creation" | "confirmation";
showDivider?: boolean;
color?: "primary" | "secondary" | "minimal" | "destructive";
preventCloseOnOutsideClick?: boolean;
enableOverflow?: boolean;
}) => (
<Dialog open={props.open} name="test-dialog">
<DialogContent
type={props.type}
title={props.title}
preventCloseOnOutsideClick={props.preventCloseOnOutsideClick}
enableOverflow={props.enableOverflow}>
<div className="flex flex-row space-x-4">
<DialogHeader title={props.title} subtitle={props.subtitle} />
<p>Dialog Content</p>
<p>{content}</p>
<DialogFooter showDivider={props.showDivider}>
<DialogClose color={props.color} />
<p>Dialog Footer</p>
<DialogClose color={props.color}>{props.color ? "Custom Close" : undefined}</DialogClose>
<p>{footerContent}</p>
</DialogFooter>
</div>
</DialogContent>
</Dialog>
);
};
describe("Tests for Dialog component", () => {
test("Should render Dialog with header", () => {
render(<DialogComponent open title={title} />);
describe("Rendering", () => {
it("renders without header when no title provided", () => {
render(<TestDialog open />);
expect(screen.queryByText("Dialog Header")).toBeInTheDocument();
expect(screen.getByText("Dialog Content")).toBeInTheDocument();
expect(screen.getByText("Dialog Footer")).toBeInTheDocument();
expect(screen.queryByTestId("dialog-title")).not.toBeInTheDocument();
expect(screen.getByText(content)).toBeInTheDocument();
});
it("renders creation type dialog", () => {
render(<TestDialog open type="creation" />);
expect(screen.getByTestId("dialog-creation")).toBeInTheDocument();
});
it("renders confirmation type dialog", () => {
render(<TestDialog open type="confirmation" />);
expect(screen.getByTestId("dialog-confirmation")).toBeInTheDocument();
});
});
test("Should render Dialog without header", () => {
render(<DialogComponent open />);
describe("Visibility", () => {
it("shows content when open", () => {
render(<TestDialog open />);
expect(screen.queryByTestId("dialog-title")).toBeNull();
expect(screen.getByText("Dialog Content")).toBeInTheDocument();
expect(screen.getByText("Dialog Footer")).toBeInTheDocument();
expect(screen.getByText(content)).toBeInTheDocument();
});
it("hides content when closed", () => {
render(<TestDialog open={false} />);
expect(screen.queryByText(content)).not.toBeInTheDocument();
});
it("toggles visibility with DialogTrigger", () => {
render(
<Dialog>
<DialogTrigger asChild>
<button>Open Dialog</button>
</DialogTrigger>
<DialogContent>
<p>{content}</p>
</DialogContent>
</Dialog>
);
expect(screen.queryByText(content)).not.toBeInTheDocument();
fireEvent.click(screen.getByText("Open Dialog"));
expect(screen.getByText(content)).toBeInTheDocument();
});
});
test("Should render Dialog with header and subtitle", () => {
render(<DialogComponent open title={title} subtitle={subtitle} />);
describe("Footer", () => {
it("shows divider when showDivider is true", () => {
render(<TestDialog open showDivider />);
expect(screen.queryByText("Dialog Header")).toBeInTheDocument();
expect(screen.queryByText("Dialog Subtitle")).toBeInTheDocument();
expect(screen.getByText("Dialog Content")).toBeInTheDocument();
expect(screen.getByText("Dialog Footer")).toBeInTheDocument();
expect(screen.getByTestId("divider")).toBeInTheDocument();
});
});
test("Should render Dialog with default type creation", () => {
render(<DialogComponent open />);
describe("Behavior", () => {
it("enables overflow when enableOverflow is true", () => {
render(<TestDialog open enableOverflow />);
expect(screen.getByTestId("dialog-creation")).toBeInTheDocument();
expect(screen.getByText("Dialog Content")).toBeInTheDocument();
expect(screen.getByText("Dialog Footer")).toBeInTheDocument();
});
test("Should render Dialog with type creation", () => {
render(<DialogComponent open type="creation" />);
expect(screen.getByTestId("dialog-creation")).toBeInTheDocument();
expect(screen.getByText("Dialog Content")).toBeInTheDocument();
expect(screen.getByText("Dialog Footer")).toBeInTheDocument();
});
test("Should render Dialog with type confirmation", () => {
render(<DialogComponent open type="confirmation" />);
expect(screen.getByTestId("dialog-confirmation")).toBeInTheDocument();
expect(screen.getByText("Dialog Content")).toBeInTheDocument();
expect(screen.getByText("Dialog Footer")).toBeInTheDocument();
});
test("Should open Dialog", async () => {
const { rerender } = render(<DialogComponent open={false} />);
expect(screen.queryByText("Dialog Content")).not.toBeInTheDocument();
expect(screen.queryByText("Dialog Footer")).not.toBeInTheDocument();
rerender(<DialogComponent open />);
expect(screen.getByText("Dialog Content")).toBeInTheDocument();
expect(screen.getByText("Dialog Footer")).toBeInTheDocument();
});
test("Should close Dialog", async () => {
const { rerender } = render(<DialogComponent open />);
expect(screen.getByText("Dialog Content")).toBeInTheDocument();
expect(screen.getByText("Dialog Footer")).toBeInTheDocument();
rerender(<DialogComponent open={false} />);
expect(screen.queryByText("Dialog Content")).not.toBeInTheDocument();
expect(screen.queryByText("Dialog Footer")).not.toBeInTheDocument();
});
test("Should use color from props in CloseDialog", async () => {
render(<DialogComponent open color="destructive" />);
const closeBtn = screen.getByText("close");
expect(closeBtn.classList.toString()).toContain("hover:text-red-700");
});
test("Should show divider with showDivider", async () => {
render(<DialogComponent open showDivider />);
expect(screen.getByTestId("divider")).toBeInTheDocument();
const dialogContent = screen.getByRole("dialog");
expect(dialogContent.className).toContain("overflow-y-auto");
});
});
});
+15 -11
View File
@@ -39,8 +39,8 @@ export const DropdownMenuContent = forwardRef<HTMLDivElement, DropdownMenuConten
{...props}
sideOffset={sideOffset}
className={classNames(
"shadow-dropdown bg-default border-subtle relative z-10 ml-1.5 origin-top-right rounded-md border text-sm",
"[&>*:first-child]:mt-1 [&>*:last-child]:mb-1",
"shadow-dropdown bg-default border-subtle relative z-10 origin-top-right space-y-[1px] rounded-xl border p-1 text-sm",
"w-[220px] [&>*:first-child]:mt-1 [&>*:last-child]:mb-1",
props.className
)}
ref={forwardedRef}>
@@ -53,14 +53,17 @@ DropdownMenuContent.displayName = "DropdownMenuContent";
type DropdownMenuLabelProps = ComponentProps<(typeof DropdownMenuPrimitive)["Label"]>;
export const DropdownMenuLabel = (props: DropdownMenuLabelProps) => (
<DropdownMenuPrimitive.Label {...props} className={classNames("text-subtle px-3 py-2", props.className)} />
<DropdownMenuPrimitive.Label
{...props}
className={classNames("text-subtle px-2 pb-1 pt-1.5 text-xs font-semibold leading-none", props.className)}
/>
);
type DropdownMenuItemProps = ComponentProps<(typeof DropdownMenuPrimitive)["CheckboxItem"]>;
export const DropdownMenuItem = forwardRef<HTMLDivElement, DropdownMenuItemProps>(
({ className = "", ...props }, forwardedRef) => (
<DropdownMenuPrimitive.Item
className={`focus:ring-brand-800 hover:bg-subtle hover:text-emphasis text-default text-sm ring-inset first-of-type:rounded-t-[inherit] last-of-type:rounded-b-[inherit] focus:outline-none focus:ring-1 ${className}`}
className={`focus:ring-brand-default hover:bg-subtle hover:text-emphasis text-default text-sm ring-inset first-of-type:rounded-t-[inherit] last-of-type:rounded-b-[inherit] hover:ring-0 focus:outline-none focus:ring-1 ${className}`}
{...props}
ref={forwardedRef}
/>
@@ -129,6 +132,7 @@ type DropdownItemProps = {
color?: ButtonColor;
StartIcon?: IconName;
CustomStartIcon?: React.ReactNode;
kbd?: string;
EndIcon?: IconName;
href?: string;
disabled?: boolean;
@@ -161,15 +165,15 @@ export const DropdownItem = (props: DropdownItemProps) => {
<ButtonOrLink
{...rest}
className={classNames(
"hover:text-emphasis text-default inline-flex w-full items-center space-x-2 px-3 py-2 disabled:cursor-not-allowed",
color === "destructive"
? "hover:bg-error hover:text-red-700 dark:hover:text-red-100"
: "hover:bg-subtle",
"hover:text-emphasis text-default inline-flex w-full items-center space-x-1 rounded-lg p-2 disabled:cursor-not-allowed",
color === "destructive" ? "hover:bg-error hover:text-error text-error" : "hover:bg-subtle",
props.className
)}>
<>
{CustomStartIcon || (StartIcon && <Icon name={StartIcon} className="h-4 w-4" />)}
<div className={classNames("text-sm font-medium leading-5", childrenClassName)}>{children}</div>
{CustomStartIcon || (StartIcon && <Icon name={StartIcon} className="mr-1 h-4 w-4" />)}
<div className={classNames("w-fit text-sm font-medium leading-none", childrenClassName)}>
{children}
</div>
{EndIcon && <Icon name={EndIcon} className="h-4 w-4" />}
</>
</ButtonOrLink>
@@ -181,7 +185,7 @@ export const DropdownMenuSeparator = forwardRef<HTMLDivElement, DropdownMenuSepa
({ className = "", ...props }, forwardedRef) => {
return (
<DropdownMenuPrimitive.Separator
className={classNames("bg-emphasis my-1 h-px", className)}
className={classNames("bg-emphasis -mx-1 my-1 h-px", className)}
{...props}
ref={forwardedRef}
/>
+1 -1
View File
@@ -77,7 +77,7 @@ export const Editor = (props: TextEditorProps) => {
return (
<div className="editor rounded-md">
<LexicalComposer initialConfig={{ ...editorConfig }}>
<div className="editor-container hover:border-emphasis focus-within:ring-brand-default rounded-md p-0 transition focus-within:ring-2">
<div className="editor-container hover:border-emphasis focus-within:ring-brand-default rounded-[10px] p-0 transition focus-within:ring-2">
<ToolbarPlugin
getText={props.getText}
setText={props.setText}
@@ -55,13 +55,11 @@ export const AddVariablesDropdown = (props: IAddVariablesDropdown) => {
type="button"
className="w-full px-4 py-2"
onClick={() => props.addVariable(t(`${variable}_variable`))}>
<div className="sm:grid sm:grid-cols-2">
<div className="mr-3 text-left md:col-span-1">
<div className="flex flex-col">
<div className="mr-text-left">
{`{${t(`${variable}_variable`).toUpperCase().replace(/ /g, "_")}}`}
</div>
<div className="text-default hidden text-left sm:col-span-1 sm:flex">
{t(`${variable}_info`)}
</div>
<div className="text-default hidden text-left sm:flex">{t(`${variable}_info`)}</div>
</div>
</button>
</DropdownMenuItem>
@@ -13,7 +13,7 @@
}
.editor-container {
border-radius: 6px;
border-radius: 10px;
position: relative;
line-height: 20px;
font-weight: 400;
@@ -1,4 +1,5 @@
import { classNames } from "@calcom/lib";
import type { IconName } from "@calcom/ui";
import {
Button,
Popover,
@@ -26,7 +27,7 @@ interface FilterSelectProps {
options: FilterOption[];
selectedValue?: string | number | null;
onChange: (value: string | number | null) => void;
buttonIcon?: React.ReactNode;
buttonIcon?: IconName;
placeholder?: string;
emptyText?: string;
testId?: string;
@@ -47,8 +48,7 @@ export function FilterSelect({
return (
<Popover>
<PopoverTrigger asChild>
<Button color="secondary" className="border-subtle rounded-md" data-testid={`${testId}-button`}>
{buttonIcon}
<Button color="secondary" data-testid={`${testId}-button`} StartIcon={buttonIcon}>
{title}
{selectedValue && (
<div className="ml-2 hidden space-x-1 md:flex">
@@ -10,7 +10,7 @@ import { Icon } from "../../icon";
type Props = InputHTMLAttributes<HTMLInputElement> & {
label?: React.ReactNode;
description: string;
description?: string;
descriptionAsLabel?: boolean;
informationIconText?: string;
error?: boolean;
@@ -63,7 +63,7 @@ const CheckboxField = forwardRef<HTMLInputElement, Props>(
</div>
)}
<div className="w-full">
<div className="relative flex items-center">
<div className="hover:bg-subtle relative flex w-fit items-center rounded-md p-1">
{React.createElement(
descriptionAsLabel ? "label" : "div",
{
@@ -94,14 +94,25 @@ const CheckboxField = forwardRef<HTMLInputElement, Props>(
</div>
{descriptionAsSafeHtml ? (
<span
className={classNames("text-sm", rest.descriptionClassName)}
className={classNames(
"text-default ml-2 text-sm",
!label && "font-medium",
rest.descriptionClassName
)}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: markdownToSafeHTML(descriptionAsSafeHtml),
}}
/>
) : (
<span className={classNames("text-sm", rest.descriptionClassName)}>{description}</span>
<span
className={classNames(
"text-default ml-2 text-sm",
!label && "font-medium",
rest.descriptionClassName
)}>
{description}
</span>
)}
</>
)}
@@ -52,7 +52,7 @@ export function HintsOrErrors<T extends FieldValues = FieldValues>({
<li
key={key}
data-testid="hint-error"
className={error !== undefined ? (submitted ? "text-red-500" : "") : "text-green-600"}>
className={error !== undefined ? (submitted ? "text-error" : "") : "text-green-600"}>
{error !== undefined ? (
submitted ? (
<Icon
+11 -20
View File
@@ -10,7 +10,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Alert } from "../../alert";
import { Icon } from "../../icon";
import { Tooltip } from "../../tooltip";
import { Input, InputField } from "../inputs/TextField";
import { Input, InputField, inputStyles } from "../inputs/TextField";
import { Label } from "./Label";
import type { InputFieldProps } from "./types";
@@ -44,7 +44,6 @@ export const PasswordField = forwardRef<HTMLInputElement, InputFieldProps>(funct
"addon-wrapper mb-0 ltr:border-r-0 ltr:pr-10 rtl:border-l-0 rtl:pl-10",
props.className
)}
addOnFilled={false}
addOnSuffix={
<Tooltip content={textLabel}>
<button
@@ -98,12 +97,9 @@ type TextAreaProps = JSX.IntrinsicElements["textarea"];
export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextAreaInput(props, ref) {
return (
<textarea
ref={ref}
{...props}
className={classNames(
"hover:border-emphasis border-default bg-default placeholder:text-muted text-emphasis disabled:hover:border-default disabled:bg-subtle focus:ring-brand-default focus:border-subtle mb-2 block w-full rounded-md border px-3 py-2 text-sm transition focus:outline-none focus:ring-2 focus:ring-offset-1 disabled:cursor-not-allowed",
props.className
)}
ref={ref}
className={classNames(inputStyles(), "min-h-[80px] w-full", props.className)}
/>
);
});
@@ -184,22 +180,17 @@ export const NumberInput = forwardRef<HTMLInputElement, InputFieldProps>(functio
);
});
export const FilterSearchField = forwardRef<HTMLInputElement, InputFieldProps>(function TextField(
export const FilterSearchField = forwardRef<HTMLInputElement, InputFieldProps>(function PasswordField(
props,
ref
) {
return (
<div
dir="ltr"
className="focus-within:ring-brand-default group relative mx-3 mb-1 mt-2.5 flex items-center rounded-md transition focus-within:outline-none focus-within:ring-2">
<div className="addon-wrapper border-default [input:hover_+_&]:border-emphasis [input:hover_+_&]:border-l-default [&:has(+_input:hover)]:border-emphasis [&:has(+_input:hover)]:border-r-default flex h-7 items-center justify-center rounded-l-md border border-r-0 transition">
<Icon name="search" className="ms-3 h-4 w-4" data-testid="search-icon" />
</div>
<Input
ref={ref}
className="disabled:bg-subtle disabled:hover:border-subtle !my-0 h-7 rounded-l-none border-l-0 !ring-0 disabled:cursor-not-allowed"
{...props}
/>
</div>
<InputField
ref={ref}
addOnLeading={<Icon name="search" className="h-4 w-4 stroke-[2.5px]" data-testid="search-icon" />}
placeholder="Search"
containerClassName="mx-3 mt-2"
{...props}
/>
);
});
@@ -5,7 +5,7 @@ type InputErrorProp = {
};
export const InputError = ({ message }: InputErrorProp) => (
<div data-testid="field-error" className="text-gray mt-2 flex items-center gap-x-2 text-sm text-red-700">
<div data-testid="field-error" className="text-error mt-2 flex items-center gap-x-2 text-sm">
<div>
<Icon name="info" className="h-3 w-3" />
</div>
@@ -1,66 +1,94 @@
"use client";
import { cva } from "class-variance-authority";
import React, { forwardRef, useId, useState } from "react";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Icon } from "../../icon";
import { Skeleton } from "../../skeleton";
import { HintsOrErrors } from "./HintOrErrors";
import { Label } from "./Label";
import type { InputFieldProps, InputProps } from "./types";
export const inputStyles = cva(
[
// Base styles
"block rounded-[10px] border",
"leading-none font-normal",
// Colors
"bg-default",
"border-default",
"text-default",
"placeholder:text-muted",
// States
"hover:border-emphasis",
"focus:ring-0",
"focus:shadow-outline-gray-focused",
// Disabled state
"disabled:bg-subtle",
"disabled:hover:border-default",
"disabled:cursor-not-allowed",
// Shadow
"shadow-outline-gray-rested",
// Transitions
"transition",
],
{
variants: {
size: {
sm: "h-7 px-2 py-1 text-xs",
md: "h-8 px-3 py-2 text-sm",
},
},
defaultVariants: {
size: "md",
},
}
);
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
{ isFullWidth = true, ...props },
{ isFullWidth = true, size = "md", className, ...props },
ref
) {
return (
<input
{...props}
ref={ref}
className={classNames(
"hover:border-emphasis dark:focus:border-emphasis border-default bg-default placeholder:text-muted text-emphasis disabled:hover:border-default disabled:bg-subtle focus:ring-brand-default focus:border-subtle mb-2 block h-9 rounded-md border px-3 py-2 text-sm leading-4 transition focus:outline-none focus:ring-2 disabled:cursor-not-allowed",
isFullWidth && "w-full",
props.className
)}
className={classNames(inputStyles({ size }), isFullWidth && "w-full", className)}
/>
);
});
type AddonProps = {
children: React.ReactNode;
isFilled?: boolean;
className?: string;
error?: boolean;
onClickAddon?: () => void;
size?: "sm" | "md";
position?: "start" | "end";
};
const Addon = ({ isFilled, children, className, error, onClickAddon }: AddonProps) => (
const Addon = ({ children, className, error, onClickAddon, size = "md", position = "start" }: AddonProps) => (
<div
onClick={onClickAddon && onClickAddon}
className={classNames(
"addon-wrapper border-default [input:hover_+_&]:border-emphasis [input:hover_+_&]:border-l-default [&:has(+_input:hover)]:border-emphasis [&:has(+_input:hover)]:border-r-default h-9 border px-3 transition",
isFilled && "bg-subtle",
onClickAddon && "cursor-pointer disabled:hover:cursor-not-allowed",
"flex flex-shrink-0 items-center justify-center whitespace-nowrap",
onClickAddon && "pointer-events-auto cursor-pointer disabled:hover:cursor-not-allowed",
className
)}>
<div
<span
className={classNames(
"min-h-9 flex flex-col justify-center text-sm leading-7",
error ? "text-error" : "text-default"
"text-sm font-medium leading-none",
error ? "text-error" : "text-muted peer-disabled:opacity-50"
)}>
<span
className="flex max-w-2xl overflow-y-auto whitespace-nowrap"
style={{
WebkitOverflowScrolling: "touch",
scrollbarWidth: "none",
overflow: "-ms-scroll-chaining",
msOverflowStyle: "-ms-autohiding-scrollbar",
}}>
{children}
</span>
</div>
{children}
</span>
</div>
);
@@ -79,7 +107,6 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function
className,
addOnLeading,
addOnSuffix,
addOnFilled = true,
addOnClassname,
inputIsFullWidth,
hint,
@@ -94,6 +121,7 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function
// eslint-disable-next-line @typescript-eslint/no-unused-vars
t: __t,
dataTestid,
size,
...passThrough
} = props;
@@ -102,10 +130,8 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function
return (
<div className={classNames(containerClassName)}>
{!!name && !noLabel && (
<Skeleton
as={Label}
<Label
htmlFor={id}
loadingClassName="w-16"
{...labelProps}
className={classNames(labelClassName, labelSrOnly && "sr-only", props.error && "text-error")}>
{label}
@@ -113,32 +139,35 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function
<span className="text-default ml-1 font-medium">*</span>
) : null}
{LockedIcon}
</Skeleton>
</Label>
)}
{addOnLeading || addOnSuffix ? (
<div
dir="ltr"
className="focus-within:ring-brand-default group relative mb-1 flex items-center rounded-md transition focus-within:outline-none focus-within:ring-2">
className={classNames(
inputStyles({ size }),
"group relative mb-1 flex min-w-0 items-center gap-1",
"[&:focus-within]:border-subtle [&:focus-within]:ring-brand-default [&:focus-within]:ring-2",
"[&:has(:disabled)]:bg-subtle [&:has(:disabled)]:hover:border-default [&:has(:disabled)]:cursor-not-allowed",
inputIsFullWidth && "w-full"
)}>
{addOnLeading && (
<Addon
isFilled={addOnFilled}
className={classNames("ltr:rounded-l-md rtl:rounded-r-md", addOnClassname)}>
<Addon size={size ?? "md"} position="start" className={classNames(addOnClassname)}>
{addOnLeading}
</Addon>
)}
<Input
data-testid={`${dataTestid}-input` ?? "input-field"}
<input
data-testid={dataTestid ? `${dataTestid}-input` : "input-field"}
id={id}
type={type}
placeholder={placeholder}
isFullWidth={inputIsFullWidth}
className={classNames(
className,
"disabled:bg-subtle disabled:hover:border-subtle disabled:cursor-not-allowed",
addOnLeading && "rounded-l-none border-l-0",
addOnSuffix && "rounded-r-none border-r-0",
type === "search" && "pr-8",
"!my-0 !ring-0"
"w-full min-w-0 truncate border-0 bg-transparent focus:outline-none focus:ring-0",
"text-default rounded-lg text-sm font-medium leading-none",
"placeholder:text-muted disabled:cursor-not-allowed disabled:bg-transparent",
addOnLeading && "pl-0.5 pr-0",
addOnSuffix && "pl-0",
className
)}
{...passThrough}
{...(type == "search" && {
@@ -153,9 +182,10 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function
/>
{addOnSuffix && (
<Addon
size={size ?? "md"}
position="end"
onClickAddon={onClickAddon}
isFilled={addOnFilled}
className={classNames("ltr:rounded-r-md rtl:rounded-l-md", addOnClassname)}>
className={classNames(addOnClassname)}>
{addOnSuffix}
</Addon>
)}
@@ -175,6 +205,7 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function
id={id}
type={type}
placeholder={placeholder}
size={size}
className={classNames(
className,
"disabled:bg-subtle disabled:hover:border-subtle disabled:cursor-not-allowed"
+13 -9
View File
@@ -1,28 +1,32 @@
import type { ReactNode } from "react";
import type { VariantProps } from "class-variance-authority";
import type { Input } from "./TextField";
import type { inputStyles } from "./TextField";
export type InputFieldProps = {
label?: ReactNode;
label?: React.ReactNode;
LockedIcon?: React.ReactNode;
hint?: ReactNode;
hint?: string;
hintErrors?: string[];
addOnLeading?: ReactNode;
addOnSuffix?: ReactNode;
addOnLeading?: React.ReactNode;
addOnSuffix?: React.ReactNode;
inputIsFullWidth?: boolean;
addOnFilled?: boolean;
addOnClassname?: string;
error?: string;
labelSrOnly?: boolean;
containerClassName?: string;
showAsteriskIndicator?: boolean;
t?: (key: string) => string;
className?: string;
placeholder?: string;
dataTestid?: string;
noLabel?: boolean;
onClickAddon?: () => void;
} & React.ComponentProps<typeof Input> & {
} & InputProps & {
labelProps?: React.ComponentProps<typeof Label>;
labelClassName?: string;
};
export type InputProps = JSX.IntrinsicElements["input"] & { isFullWidth?: boolean };
export type InputProps = Omit<JSX.IntrinsicElements["input"], "size" | "ref"> &
VariantProps<typeof inputStyles> & {
isFullWidth?: boolean;
};
+40 -15
View File
@@ -7,13 +7,19 @@ import cx from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Label } from "../inputs/Label";
import { inputStyles } from "../inputs/TextField";
import { getReactSelectProps } from "./selectTheme";
export type SelectProps<
Option,
IsMulti extends boolean = false,
Group extends GroupBase<Option> = GroupBase<Option>
> = Props<Option, IsMulti, Group> & { variant?: "default" | "checkbox"; "data-testid"?: string };
> = Props<Option, IsMulti, Group> & {
variant?: "default" | "checkbox";
"data-testid"?: string;
size?: "sm" | "md";
grow?: boolean;
};
export const Select = <
Option,
@@ -22,6 +28,8 @@ export const Select = <
>({
components,
variant = "default",
size = "md",
grow,
...props
}: SelectProps<Option, IsMulti, Group> & {
innerClassNames?: {
@@ -43,17 +51,26 @@ export const Select = <
});
}, [components, menuPlacement]);
const hasMultiLastIcons = props.isMulti || props.isLoading || props.isClearable;
// Annoyingly if we update styles here we have to update timezone select too
// We cant create a generate function for this as we can't force state changes - onSelect styles dont change for example
return (
<ReactSelect
{...reactSelectProps}
menuPlacement={menuPlacement}
styles={{
control: (base) => ({
...base,
minHeight: size === "sm" ? "28px" : "36px",
height: grow ? "h-auto " : size === "sm" ? "28px" : "36px",
}),
}}
classNames={{
input: () => cx("text-emphasis", innerClassNames?.input),
option: (state) =>
cx(
"bg-default flex cursor-pointer justify-between py-2.5 px-3 rounded-none text-default ",
"bg-default flex cursor-pointer justify-between py-1.5 px-2 rounded-md text-default items-center",
state.isFocused && "bg-subtle",
state.isDisabled && "bg-muted",
state.isSelected && "bg-emphasis text-default",
@@ -63,41 +80,49 @@ export const Select = <
dropdownIndicator: () => "text-default",
control: (state) =>
cx(
"bg-default border-default !min-h-9 h-9 text-sm leading-4 placeholder:text-sm placeholder:font-normal dark:focus:border-emphasis focus-within:outline-none focus-within:ring-2 focus-within:ring-brand-default hover:border-emphasis rounded-md transition border",
inputStyles({ size }),
state.isMulti
? variant === "checkbox"
? "px-3 py-2 h-fit"
? "px-3 h-fit"
: state.hasValue
? "p-1 h-fit"
: "px-3 py-2 h-fit"
: "py-2 px-3",
: "px-3 h-fit"
: size === "sm"
? "h-7 px-2"
: "h-9 px-3",
props.isDisabled && "bg-subtle",
size === "sm" ? "rounded-md" : "rounded-[10px]",
"[&:focus-within]:border-emphasis [&:focus-within]:shadow-outline-gray-focused [&:focus-within]:ring-0 !flex",
innerClassNames?.control
),
singleValue: () => cx("text-emphasis placeholder:text-muted", innerClassNames?.singleValue),
singleValue: () => cx("text-default placeholder:text-muted", innerClassNames?.singleValue),
valueContainer: () =>
cx("text-emphasis placeholder:text-muted flex gap-1", innerClassNames?.valueContainer),
cx("text-default placeholder:text-muted flex gap-1", innerClassNames?.valueContainer),
multiValue: () =>
cx(
"bg-subtle text-default rounded-md py-1.5 px-2 flex items-center text-sm leading-tight",
innerClassNames?.multiValue
"font-medium inline-flex items-center justify-center rounded bg-emphasis text-emphasis leading-none text-xs",
size == "sm" ? "px-1.5 py-[1px] rounded-md" : "py-1 px-1.5 leading-none rounded-lg"
),
menu: () =>
cx(
" rounded-md bg-default text-sm leading-4 text-default mt-1 border border-subtle",
"rounded-lg bg-default text-sm leading-4 text-default mt-1 border border-subtle shadow-dropdown p-1",
innerClassNames?.menu
),
groupHeading: () => "leading-none text-xs uppercase text-default pl-2.5 pt-4 pb-2",
menuList: () => cx("scroll-bar scrollbar-track-w-20 rounded-md", innerClassNames?.menuList),
groupHeading: () => "leading-none text-xs text-muted p-2 font-medium ml-1",
menuList: () =>
cx(
"scroll-bar scrollbar-track-w-20 rounded-md flex flex-col space-y-[1px]",
innerClassNames?.menuList
),
indicatorsContainer: (state) =>
cx(
state.selectProps.menuIsOpen
? state.isMulti
? hasMultiLastIcons
? "[&>*:last-child]:rotate-180 [&>*:last-child]:transition-transform"
: "rotate-180 transition-transform"
: "text-default" // Woo it adds another SVG here on multi for some reason
),
multiValueRemove: () => "text-default py-auto ml-2",
multiValueRemove: () => "text-default py-auto",
...classNames,
}}
{...restProps}
@@ -0,0 +1,119 @@
"use client";
import * as Popover from "@radix-ui/react-popover";
import { useState } from "react";
import { Badge, Button } from "@calcom/ui";
import { inputStyles, TextField } from "../inputs/TextField";
import { Slider } from "./index";
interface RangeSliderPopoverProps {
triggerText: string;
value: number[];
onChange: (value: number[]) => void;
min: number;
max: number;
step?: number;
badgeVariant?: "default" | "success" | "gray" | "warning" | "orange" | "red";
badgeSuffix?: string;
inputSuffix?: string;
inputLeading?: string;
}
export const RangeSliderPopover = ({
triggerText,
value,
onChange,
min,
max,
step = 1,
badgeVariant = "default",
badgeSuffix,
inputSuffix,
inputLeading,
}: RangeSliderPopoverProps) => {
const [internalValue, setInternalValue] = useState<number[]>(value);
const [open, setOpen] = useState(false);
const handleReset = () => {
setInternalValue([min, max]);
};
const handleApply = () => {
onChange(internalValue);
setOpen(false);
};
return (
<Popover.Root open={open} onOpenChange={setOpen}>
<Popover.Trigger asChild>
<button className={inputStyles()}>
<span className="text-subtle text-sm font-medium leading-none">{triggerText}:</span>
{value && (
<Badge variant={badgeVariant} className="ml-2">
{value[0]} - {value[1]} {badgeSuffix}
</Badge>
)}
</button>
</Popover.Trigger>
<Popover.Portal>
<Popover.Content
align="start"
className="border-subtle shadow-dropdown bg-default z-50 mt-2 w-72 rounded-lg border-[1px] px-4 pb-3 pt-4 font-[family-name:var(--font-inter)]">
<div className="mb-4">
<Slider min={min} max={max} step={step} value={internalValue} onValueChange={setInternalValue} />
</div>
<div className="mb-4 flex items-center justify-between gap-2">
<TextField
labelSrOnly
name="start"
type="number"
min={min}
max={internalValue[1]}
value={internalValue[0]}
onChange={(e) => {
const newValue = parseInt(e.target.value);
if (!isNaN(newValue) && newValue >= min && newValue <= internalValue[1]) {
setInternalValue([newValue, internalValue[1]]);
}
}}
addOnLeading={inputLeading ? inputLeading : undefined}
addOnSuffix={inputSuffix ? inputSuffix : undefined}
containerClassName="w-full"
/>
<TextField
labelSrOnly
name="end"
type="number"
min={internalValue[0]}
max={max}
value={internalValue[1]}
onChange={(e) => {
const newValue = parseInt(e.target.value);
if (!isNaN(newValue) && newValue >= internalValue[0] && newValue <= max) {
setInternalValue([internalValue[0], newValue]);
}
}}
addOnLeading={inputLeading ? inputLeading : undefined}
addOnSuffix={inputSuffix ? inputSuffix : undefined}
containerClassName="w-full"
/>
</div>
<div className="-mx-4">
<hr className="border-subtle" />
<div className="mt-3 flex items-center justify-end gap-2 px-4">
<Button color="minimal" size="sm" onClick={handleReset}>
Reset
</Button>
<Button color="secondary" size="sm" onClick={handleApply}>
Apply
</Button>
</div>
</div>
</Popover.Content>
</Popover.Portal>
</Popover.Root>
);
};
@@ -0,0 +1,25 @@
"use client";
import * as SliderPrimitive from "@radix-ui/react-slider";
import * as React from "react";
import classNames from "@calcom/lib/classNames";
const Slider = React.forwardRef<
React.ElementRef<typeof SliderPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
>(({ className, ...props }, ref) => (
<SliderPrimitive.Root
ref={ref}
className={classNames("relative flex w-full touch-none select-none items-center", className)}
{...props}>
<SliderPrimitive.Track className="bg-subtle border-subtle relative h-2 w-full grow overflow-hidden rounded-full border-[1px]">
<SliderPrimitive.Range className="bg-brand-default absolute h-full" />
</SliderPrimitive.Track>
<SliderPrimitive.Thumb className="border-subtle bg-brand-default ring-offset-background focus-visible:ring-ring block h-4 w-4 rounded-full border-2 border-[1px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
<SliderPrimitive.Thumb className="border-subtle bg-brand-default ring-offset-background focus-visible:ring-ring block h-4 w-4 rounded-full border-2 border-[1px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
</SliderPrimitive.Root>
));
Slider.displayName = SliderPrimitive.Root.displayName;
export { Slider };
+27 -18
View File
@@ -20,45 +20,53 @@ const Switch = (
fitToHeight?: boolean;
disabled?: boolean;
tooltip?: string;
small?: boolean;
labelOnLeading?: boolean;
size?: "base" | "sm";
classNames?: {
container?: string;
thumb?: string;
};
LockedIcon?: React.ReactNode;
padding?: boolean;
}
) => {
const { label, fitToHeight, classNames, small, labelOnLeading, LockedIcon, ...primitiveProps } = props;
const {
label,
fitToHeight,
classNames,
labelOnLeading,
LockedIcon,
padding,
size = "base",
...primitiveProps
} = props;
const id = useId();
const isChecked = props.checked || props.defaultChecked;
return (
<Wrapper tooltip={props.tooltip}>
<div
className={cx(
"flex h-auto w-auto flex-row items-center",
"flex h-auto w-fit flex-row items-center",
fitToHeight && "h-fit",
labelOnLeading && "flex-row-reverse",
padding && "hover:bg-subtle rounded-md p-1.5",
classNames?.container
)}>
{LockedIcon && <div className="mr-2">{LockedIcon}</div>}
<PrimitiveSwitch.Root
{...primitiveProps}
id={id}
className={cx(
isChecked ? "bg-brand-default dark:bg-brand-emphasis" : "bg-emphasis",
primitiveProps.disabled && "cursor-not-allowed",
small ? "h-4 w-[27px]" : "h-5 w-[34px]",
"focus:ring-brand-default rounded-full shadow-none transition focus:border-neutral-300 focus:outline-none focus:ring-2 focus:ring-neutral-800 focus:ring-offset-1",
props.className
)}
{...primitiveProps}>
size === "sm" ? "h-3 w-[20px]" : "h-4 w-[28px]",
"focus:ring-brand-default data-[state=checked]:bg-brand-default dark:data-[state=checked]:bg-brand-emphasis data-[state=unchecked]:bg-emphasis peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-inner transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
size === "sm" ? "h-4 w-7" : "h-6 w-11",
classNames?.container
)}>
<PrimitiveSwitch.Thumb
id={id}
className={cx(
small
? "h-[10px] w-[10px] ltr:translate-x-[2px] rtl:-translate-x-[2px] ltr:[&[data-state='checked']]:translate-x-[13px] rtl:[&[data-state='checked']]:-translate-x-[13px]"
: "h-[14px] w-[14px] ltr:translate-x-[4px] rtl:-translate-x-[4px] ltr:[&[data-state='checked']]:translate-x-[17px] rtl:[&[data-state='checked']]:-translate-x-[17px]",
"block rounded-full transition will-change-transform",
isChecked ? "bg-brand-accent shadow-inner" : "bg-default",
"bg-default data-[state=checked]:bg-brand-accent shadow-switch-thumb pointer-events-none block rounded-full shadow-lg ring-0 transition-transform",
size === "sm"
? "h-3 w-3 data-[state=checked]:translate-x-3 data-[state=unchecked]:translate-x-0"
: "h-5 w-5 data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
classNames?.thumb
)}
/>
@@ -67,7 +75,8 @@ const Switch = (
<Label.Root
htmlFor={id}
className={cx(
"text-emphasis ms-2 align-text-top text-sm font-medium",
"text-emphasis align-text-top font-medium",
size === "sm" ? "m-1 text-xs" : "m-2 text-sm",
primitiveProps.disabled ? "cursor-not-allowed opacity-25" : "cursor-pointer",
labelOnLeading && "flex-1"
)}>
@@ -10,6 +10,7 @@ import { filterBySearchText, addTimezonesToDropdown, handleOptionLabel } from "@
import type { Timezones } from "@calcom/lib/timezone";
import { trpc } from "@calcom/trpc/react";
import { inputStyles } from "../inputs/TextField";
import { getReactSelectProps } from "../select";
const SELECT_SEARCH_DATA: Timezones = [
@@ -37,6 +38,8 @@ const SELECT_SEARCH_DATA: Timezones = [
export type TimezoneSelectProps = SelectProps & {
variant?: "default" | "minimal";
timezoneSelectCustomClassname?: string;
size?: "sm" | "md";
grow?: boolean;
};
export function TimezoneSelect(props: TimezoneSelectProps) {
const { data = [], isPending } = trpc.viewer.timezones.cityTimezones.useQuery(
@@ -61,7 +64,10 @@ export type TimezoneSelectComponentProps = SelectProps & {
isPending: boolean;
data?: Timezones;
timezoneSelectCustomClassname?: string;
size?: "sm" | "md";
grow?: boolean;
};
export function TimezoneSelectComponent({
className,
classNames: timezoneClassNames,
@@ -70,6 +76,8 @@ export function TimezoneSelectComponent({
variant = "default",
isPending,
value,
size = "md",
grow = false,
...props
}: TimezoneSelectComponentProps) {
const data = [...(props.data || []), ...SELECT_SEARCH_DATA];
@@ -103,6 +111,13 @@ export function TimezoneSelectComponent({
...(props.data ? addTimezonesToDropdown(data) : {}),
...addTimezonesToDropdown(additionalTimezones),
}}
styles={{
control: (base) => ({
...base,
minHeight: size === "sm" ? "28px" : "36px",
height: grow ? "h-auto " : size === "sm" ? "28px" : "36px",
}),
}}
onInputChange={handleInputChange}
{...props}
formatOptionLabel={(option) => (
@@ -118,19 +133,26 @@ export function TimezoneSelectComponent({
),
option: (state) =>
classNames(
"bg-default flex !cursor-pointer justify-between py-2.5 px-3 rounded-none text-default ",
"bg-default flex cursor-pointer justify-between py-2.5 px-3 rounded-md text-default ",
state.isFocused && "bg-subtle",
state.isSelected && "bg-emphasis",
state.isDisabled && "bg-muted",
state.isSelected && "bg-emphasis text-default",
timezoneClassNames?.option && timezoneClassNames.option(state)
),
placeholder: (state) => classNames("text-muted", state.isFocused && "hidden"),
dropdownIndicator: () => "text-default",
control: (state) =>
classNames(
"!cursor-pointer",
variant === "default"
? "px-3 py-2 bg-default border-default !min-h-9 text-sm leading-4 placeholder:text-sm placeholder:font-normal focus-within:ring-2 focus-within:ring-emphasis hover:border-emphasis rounded-md border gap-1"
: "text-sm gap-1",
inputStyles({ size }),
state.isMulti
? state.hasValue
? "p-1 h-fit"
: "px-3 h-fit"
: size === "sm"
? "h-7 px-2"
: "h-9 px-3",
props.isDisabled && "bg-subtle",
"rounded-[10px]",
timezoneClassNames?.control && timezoneClassNames.control(state)
),
singleValue: (state) =>
@@ -13,6 +13,7 @@ interface ToggleGroupProps extends Omit<RadixToggleGroup.ToggleGroupSingleProps,
iconLeft?: ReactNode;
}[];
isFullWidth?: boolean;
orientation?: "horizontal" | "vertical";
}
const OptionalTooltipWrapper = ({
@@ -36,6 +37,7 @@ export const ToggleGroup = ({
options,
onValueChange,
isFullWidth,
orientation = "horizontal",
customClassNames,
...props
}: ToggleGroupProps & { customClassNames?: string }) => {
@@ -44,9 +46,12 @@ export const ToggleGroup = ({
<RadixToggleGroup.Root
type="single"
{...props}
orientation={orientation}
onValueChange={onValueChange}
className={classNames(
`min-h-9 border-default bg-default relative inline-flex gap-0.5 rounded-md border p-1 rtl:flex-row-reverse`,
`border-default bg-default relative rounded-md border p-1`,
orientation === "horizontal" && "min-h-9 inline-flex gap-0.5 rtl:flex-row-reverse",
orientation === "vertical" && "flex w-fit flex-col gap-0.5",
props.className,
isFullWidth && "w-full",
customClassNames
@@ -64,8 +69,13 @@ export const ToggleGroup = ({
: "text-default [&[aria-checked='false']]:hover:text-emphasis",
isFullWidth && "w-full"
)}>
<div className="item-center flex justify-center ">
{option.iconLeft && <span className="mr-2 flex h-4 w-4 items-center">{option.iconLeft}</span>}
<div
className={classNames(
"flex items-center gap-2",
orientation === "horizontal" && "justify-center",
orientation === "vertical" && "justify-start"
)}>
{option.iconLeft && <span className="flex h-4 w-4 items-center">{option.iconLeft}</span>}
{option.label}
</div>
</RadixToggleGroup.Item>
@@ -118,9 +118,10 @@ describe("Tests for WizardForm component", () => {
test("Should disable 'Next step' button if current step navigation is not enabled", async () => {
currentStepNavigation = 1;
const { nextLabel } = props;
const { getByText } = renderComponent();
const { getByRole } = renderComponent();
expect(getByText(nextLabel)).toBeDisabled();
const nextButton = getByRole("button", { name: nextLabel });
expect(nextButton).toBeDisabled();
});
test("Should handle when navigation is disabled", async () => {
@@ -1,3 +1,5 @@
"use client";
import type { NextSeoProps } from "next-seo";
import { NextSeo } from "next-seo";
import { usePathname } from "next/navigation";
@@ -1,2 +1,101 @@
/* TODO: Implement NavigationItem */
export {};
import { cva } from "class-variance-authority";
import { Fragment } from "react";
import { classNames } from "@calcom/lib";
import { ButtonOrLink } from "../dropdown";
import { Icon } from "../icon";
import type { IconName } from "../icon";
export type NavigationItemType = {
isLastChild?: boolean;
isExpanded?: boolean;
onToggle?: () => void;
name: string;
href?: string;
isLoading?: boolean;
badge?: React.ReactNode;
icon?: IconName;
child?: NavigationItemType[];
onlyMobile?: boolean;
onlyDesktop?: boolean;
moreOnMobile?: boolean;
isCurrent?: boolean;
};
const navigationItemStyles = cva(
"text-default group flex items-center rounded-[10px] p-2 text-sm font-medium transition hover:bg-subtle hover:text-emphasis",
{
variants: {
isChild: {
true: "[&[aria-current='page']]:text-emphasis [&[aria-current='page']]:bg-emphasis hidden h-8 ml-16 lg:flex lg:ml-10 relative before:absolute before:left-[-24px] before:top-[-0.5rem] before:h-[calc(100%+0.5rem)] before:w-0.5 before:bg-subtle before:content-[''] [&:first-child]:before:rounded-t-full [&:last-child]:before:rounded-b-full",
false: "[&[aria-current='page']]:text-emphasis mt-0.5 text-sm",
},
hasChild: {
true: "[&[aria-current='page']]:!bg-transparent relative after:absolute after:left-[-24px] after:top-[1.5rem] after:h-[calc(100%-1.5rem)] after:w-0.5 after:bg-subtle after:content-[''] [&:first-child]:after:rounded-t-full [&:last-child]:after:rounded-b-full",
false: "[&[aria-current='page']]:bg-subtle",
},
isFirstChild: {
true: "mt-0",
false: "mt-px",
},
},
defaultVariants: {
isChild: false,
hasChild: false,
isFirstChild: false,
},
}
);
const Label = ({ children }: { children: React.ReactNode }) => {
return <span className="text-default ml-3">{children}</span>;
};
const NavigationItemComponent = ({
item,
isChild,
index,
}: {
item: NavigationItemType;
isChild?: boolean;
index?: number;
}) => {
return (
<Fragment>
<ButtonOrLink
data-test-id={item.name}
href={item.href}
className={navigationItemStyles({
isChild,
hasChild: !!item.child,
isFirstChild: isChild && index === 0,
})}
aria-current={item.isCurrent ? "page" : undefined}
onClick={item.onToggle}>
{item.icon && (
<Icon
name={item.isLoading ? "rotate-cw" : item.icon}
className={classNames(
"text-subtle mr-2 h-4 w-4 flex-shrink-0 rtl:ml-2 md:ltr:mx-auto lg:ltr:mr-2",
item.isLoading && "animate-spin"
)}
aria-hidden="true"
aria-current={item.isCurrent ? "page" : undefined}
/>
)}
<span className="text-emphasis hidden w-full justify-between truncate text-ellipsis lg:flex">
{item.name}
{item.badge && item.badge}
</span>
</ButtonOrLink>
{item.child &&
item.isExpanded &&
item.child.map((childItem, childIndex) => (
<NavigationItem key={childItem.name} item={childItem} isChild index={childIndex} />
))}
</Fragment>
);
};
export const NavigationItem = Object.assign(NavigationItemComponent, { Label });
@@ -1,13 +1,11 @@
import Link from "next/link";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { useUrlMatchesCurrentUrl } from "@calcom/lib/hooks/useUrlMatchesCurrentUrl";
import { Avatar } from "../../avatar";
import { Icon } from "../../icon";
import type { IconName } from "../../icon";
import { SkeletonText } from "../../skeleton";
export type HorizontalTabItemProps = {
name: string;
@@ -21,6 +19,7 @@ export type HorizontalTabItemProps = {
avatar?: string;
onClick?: (name: string) => void;
isActive?: boolean;
"data-testid"?: string;
};
const HorizontalTabItem = function ({
@@ -31,8 +30,6 @@ const HorizontalTabItem = function ({
avatar,
...props
}: HorizontalTabItemProps) {
const { t, isLocaleReady } = useLocale();
const isCurrent = useUrlMatchesCurrentUrl(href) || props?.isActive;
return (
@@ -47,32 +44,24 @@ const HorizontalTabItem = function ({
href={href}
shallow={linkShallow}
scroll={linkScroll}
aria-disabled={props.disabled ? "true" : undefined}
className={classNames(
isCurrent ? "bg-emphasis text-emphasis" : "hover:bg-subtle hover:text-emphasis text-default",
"inline-flex items-center justify-center whitespace-nowrap rounded-[6px] p-2 text-sm font-medium leading-4 transition md:mb-0",
isCurrent ? "bg-subtle text-emphasis" : "hover:bg-muted hover:text-default text-subtle",
"inline-flex h-fit items-center justify-center whitespace-nowrap rounded-md p-2 text-sm font-medium leading-none transition md:mb-0",
props.disabled && "pointer-events-none !opacity-30",
props.className
)}
target={props.target ? props.target : undefined}
data-testid={`horizontal-tab-${name}`}
data-testid={`horizontal-tab-${props["data-testid"]}`}
aria-current={isCurrent ? "page" : undefined}>
{props.icon && (
<Icon
name={props.icon}
className={classNames(
isCurrent ? "text-emphasis" : "group-hover:text-subtle text-muted",
"-ml-0.5 hidden h-4 w-4 ltr:mr-2 rtl:ml-2 sm:inline-block"
)}
className={classNames("-ml-0.5 me-2 hidden h-4 w-4 text-inherit sm:inline-block")}
aria-hidden="true"
/>
)}
{isLocaleReady ? (
<div className="flex items-center gap-x-2">
{avatar && <Avatar size="sm" imageSrc={avatar} alt="avatar" />} {t(name)}
</div>
) : (
<SkeletonText className="h-4 w-24" />
)}
{avatar && <Avatar size="xs" imageSrc={avatar} alt="avatar" className="-ml-0.5 me-1" />} {name}
</Link>
);
};
@@ -10,19 +10,13 @@ export interface NavTabProps {
const HorizontalTabs = function ({ tabs, linkShallow, linkScroll, actions, ...props }: NavTabProps) {
return (
<div className="mb-4 h-9 max-w-full lg:mb-5">
<div className="mb-4 max-w-full lg:mb-5">
<nav
className="no-scrollbar flex max-h-9 space-x-1 overflow-x-scroll rounded-md"
className="no-scrollbar flex space-x-0.5 overflow-x-scroll rounded-md"
aria-label="Tabs"
{...props}>
{tabs.map((tab, idx) => (
<HorizontalTabItem
className="px-4 py-2.5"
{...tab}
key={idx}
linkShallow={linkShallow}
linkScroll={linkScroll}
/>
<HorizontalTabItem {...tab} key={idx} linkShallow={linkShallow} linkScroll={linkScroll} />
))}
</nav>
{actions && actions}
@@ -2,12 +2,10 @@ import Link from "next/link";
import { Fragment } from "react";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { useUrlMatchesCurrentUrl } from "@calcom/lib/hooks/useUrlMatchesCurrentUrl";
import { Icon } from "../../icon";
import type { IconName } from "../../icon";
import { Skeleton } from "../../skeleton";
export type VerticalTabItemProps = {
name: string;
@@ -28,6 +26,7 @@ export type VerticalTabItemProps = {
iconClassName?: string;
onClick?: (name: string) => void;
isActive?: boolean;
"data-testid"?: string;
};
const VerticalTabItem = ({
@@ -40,7 +39,6 @@ const VerticalTabItem = ({
linkScroll,
...props
}: VerticalTabItemProps) => {
const { t } = useLocale();
const isCurrent = useUrlMatchesCurrentUrl(href) || props?.isActive;
return (
@@ -58,42 +56,34 @@ const VerticalTabItem = ({
href={href}
shallow={linkShallow}
scroll={linkScroll}
aria-disabled={props.disabled ? "true" : undefined}
target={props.isExternalLink ? "_blank" : "_self"}
className={classNames(
props.textClassNames || "text-default text-sm font-medium leading-none",
"min-h-7 hover:bg-subtle [&[aria-current='page']]:bg-emphasis [&[aria-current='page']]:text-emphasis group-hover:text-default group flex w-64 flex-row items-center rounded-md px-3 py-2 transition",
"hover:bg-subtle [&[aria-current='page']]:bg-subtle [&[aria-current='page']]:text-emphasis group-hover:text-default group flex w-full flex-row items-center rounded-md p-2 transition",
props.disabled && "pointer-events-none !opacity-30",
(isChild || !props.icon) && "ml-7 w-auto ltr:mr-5 rtl:ml-5",
!info ? "h-6" : "h-auto",
(isChild || !props.icon) && "ml-7",
props.className
)}
data-testid={`vertical-tab-${name}`}
data-testid={`vertical-tab-${props["data-testid"]}`}
aria-current={isCurrent ? "page" : undefined}>
{props.icon && (
<Icon
name={props.icon}
className={classNames(
"mr-2 h-[16px] w-[16px] stroke-[2px] ltr:mr-2 rtl:ml-2 md:mt-0",
props.iconClassName
)}
className={classNames("me-2 h-4 w-4", props.iconClassName)}
data-testid="icon-component"
/>
)}
<div className="h-fit">
<span className="flex items-center space-x-2 rtl:space-x-reverse">
<Skeleton title={t(name)} as="p" className="max-w-36 min-h-4 truncate">
{t(name)}
</Skeleton>
<div className="h-fit min-w-0 flex-1">
<span className="flex items-center gap-2 truncate">
{name}
{props.isExternalLink ? <Icon name="external-link" data-testid="external-link" /> : null}
</span>
{info && (
<Skeleton
data-testid="apps-info"
as="p"
title={t(info)}
className="max-w-44 mt-1 truncate text-xs font-normal">
{t(info)}
</Skeleton>
// TODO: I don't think having apps-info as a data-test-id is right here as this is meant to be dumb component.
<p data-testid="apps-info" className="mt-1 truncate text-xs font-normal">
{info}
</p>
)}
</div>
{!disableChevron && isCurrent && (
@@ -32,6 +32,9 @@ const NavTabs = function ({
`no-scrollbar flex flex-col space-y-0.5 overflow-scroll ${className}`,
sticky && "sticky top-0 -mt-7"
)}
style={{
maxWidth: "256px",
}}
aria-label="Tabs"
{...props}>
{/* padding top for sticky */}
@@ -1,145 +1,215 @@
/* eslint-disable playwright/missing-playwright-await */
import { fireEvent, render, screen } from "@testing-library/react";
import { vi } from "vitest";
import type { IconName } from "../../icon";
import HorizontalTabs from "./HorizontalTabs";
import VerticalTabs from "./VerticalTabs";
// Mock the hooks
vi.mock("@calcom/lib/hooks/useUrlMatchesCurrentUrl", () => ({
useUrlMatchesCurrentUrl() {
return {
route: "/",
pathname: "",
query: "",
asPath: "",
push: vi.fn(),
events: {
on: vi.fn(),
off: vi.fn(),
},
beforePopState: vi.fn(() => null),
prefetch: vi.fn(() => null),
};
},
useUrlMatchesCurrentUrl: () => false,
}));
vi.mock("@calcom/lib/hooks/useLocale", () => ({
useLocale: () => {
return {
t: (str: string) => str,
isLocaleReady: true,
i18n: {
language: "en",
defaultLocale: "en",
locales: ["en"],
exists: () => false,
},
};
},
useLocale: () => ({
t: (str: string) => str,
isLocaleReady: true,
i18n: {
language: "en",
defaultLocale: "en",
locales: ["en"],
},
}),
}));
describe("Tests for navigation folder", () => {
describe("Test HorizontalTabs Component", () => {
describe("Navigation Components", () => {
describe("HorizontalTabs", () => {
const mockTabs = [
{ name: "Tab 1", href: "/tab1" },
{ name: "Tab 2", href: "/tab2", avatar: "Avatar" },
{ name: "Tab 3", href: "/tab3" },
];
{ name: "Dashboard", href: "/dashboard", "data-testid": "dashboard" },
{ name: "Settings", href: "/settings", icon: "atom", "data-testid": "settings" },
{ name: "Profile", href: "/profile", avatar: "user-avatar", "data-testid": "profile" },
{ name: "Disabled", href: "/disabled", disabled: true, "data-testid": "disabled" },
] as {
name: string;
href: string;
icon?: IconName;
avatar?: string;
disabled?: boolean;
"data-testid"?: string;
}[];
beforeEach(() => {
vi.clearAllMocks();
});
test("Should render tabs with correct name and href", () => {
test("renders all tabs with correct name and href", async () => {
render(<HorizontalTabs tabs={mockTabs} />);
mockTabs.forEach((tab) => {
const tabLabelElement = screen.getByTestId(`horizontal-tab-${tab.name}`);
expect(tabLabelElement).toBeInTheDocument();
const name = screen.getByText(tab.name);
expect(name).toBeInTheDocument();
expect(tabLabelElement).toHaveAttribute("href", tab.href);
});
for (const tab of mockTabs) {
const tabElement = screen.getByTestId(`horizontal-tab-${tab["data-testid"]}`);
expect(tabElement).toBeInTheDocument();
await expect(tabElement).toHaveAttribute("href", tab.href);
}
});
test("Should render actions correctly", () => {
const handleClick = vi.fn();
const mockActions = <button onClick={handleClick}>Actions</button>;
render(<HorizontalTabs tabs={mockTabs} actions={mockActions} />);
const actionsElement = screen.getByText("Actions");
expect(actionsElement).toBeInTheDocument();
fireEvent.click(actionsElement);
test("renders disabled tabs with correct aria-disabled attribute", async () => {
render(<HorizontalTabs tabs={mockTabs} />);
expect(handleClick).toHaveBeenCalled();
const disabledTab = mockTabs.find((tab) => tab.disabled);
// Just to keep TS happy
// eslint-disable-next-line playwright/no-conditional-in-test
if (!disabledTab) throw new Error("Test requires a disabled tab in mockTabs");
const tabElement = screen.getByTestId(`horizontal-tab-${disabledTab["data-testid"]}`);
await expect(tabElement).toHaveAttribute("aria-disabled", "true");
});
test("renders actions when provided", async () => {
const mockAction = <button>Add New</button>;
render(<HorizontalTabs tabs={mockTabs} actions={mockAction} />);
expect(screen.getByRole("button", { name: "Add New" })).toBeInTheDocument();
});
test("handles tab click events", () => {
const handleClick = vi.fn();
const tabsWithClick = [{ name: "Tab", href: "/tab", onClick: handleClick, "data-testid": "tab" }];
render(<HorizontalTabs tabs={tabsWithClick} />);
fireEvent.click(screen.getByTestId("horizontal-tab-tab"));
expect(handleClick).toHaveBeenCalledWith("Tab");
});
});
describe("Test VerticalTabs Component", () => {
describe("VerticalTabs", () => {
const mockTabs = [
{
name: "Tab 1",
href: "/tab1",
disableChevron: true,
disabled: true,
icon: "plus" as const,
name: "Overview",
href: "/overview",
icon: "home",
info: "Main dashboard view",
"data-testid": "Overview",
},
{ name: "Tab 2", href: "/tab2", isExternalLink: true },
{ name: "Tab 3", href: "/tab3", info: "info" },
];
{
name: "External",
href: "https://external.com",
isExternalLink: true,
icon: "external",
"data-testid": "Exteral",
},
{
name: "Disabled",
href: "/disabled",
disabled: true,
icon: "lock",
"data-testid": "Disabled",
},
{
name: "Child Tab",
href: "/child",
isChild: true,
disableChevron: true,
"data-testid": "Child Tab",
},
] as {
name: string;
href: string;
icon?: IconName;
avatar?: string;
disabled?: boolean;
isExternalLink?: boolean;
isChild?: boolean;
disableChevron?: boolean;
info?: string;
"data-testid"?: string;
}[];
beforeEach(() => {
vi.clearAllMocks();
});
test("Should render tabs with correct name and href", () => {
render(<VerticalTabs tabs={mockTabs} />);
mockTabs.forEach((tab) => {
const tabLabelElement = screen.getByTestId(`vertical-tab-${tab.name}`);
expect(tabLabelElement).toBeInTheDocument();
test("renders all tabs with correct structure and attributes", async () => {
const { container } = render(<VerticalTabs tabs={mockTabs} sticky className="custom-class" />);
const name = screen.getByText(tab.name);
expect(name).toBeInTheDocument();
expect(tabLabelElement).toHaveAttribute("href", tab.href);
});
});
mockTabs.forEach(async (tab) => {
const tabElement = screen.getByTestId(`vertical-tab-${tab["data-testid"]}`);
expect(tabElement).toBeInTheDocument();
await expect(tabElement).toHaveAttribute("href", tab.href);
test("Should render correctly if props are passed", async () => {
render(<VerticalTabs tabs={mockTabs} />);
const iconElement = await screen.findAllByTestId("icon-component");
const externalLink = await screen.findAllByTestId("external-link");
const chevronRight = await screen.findAllByTestId("chevron-right");
mockTabs.forEach((tab) => {
const tabName = screen.getByText(tab.name);
expect(tabName).toBeInTheDocument();
const aTag = screen.getByTestId(`vertical-tab-${tab.name}`);
const tabContainer = tabName.closest("a");
const infoElement = tabContainer?.querySelector("p[title='info']");
expect(chevronRight.length).toEqual(mockTabs.length - 1);
if (tab.disabled) {
expect(aTag).tabToBeDisabled();
} else {
expect(aTag).not.tabToBeDisabled();
}
if (tab.info) {
expect(infoElement).toBeInTheDocument();
} else {
expect(infoElement).toBeNull();
await expect(tabElement).toHaveAttribute("aria-disabled", "true");
}
if (tab.isExternalLink) {
expect(aTag).toHaveAttribute("target", "_blank");
} else {
expect(aTag).toHaveAttribute("target", "_self");
await expect(tabElement).toHaveAttribute("target", "_blank");
expect(screen.getByTestId("external-link")).toBeInTheDocument();
}
if (tab.info) {
const infoElement = screen.getByTestId("apps-info");
expect(infoElement).toBeInTheDocument();
expect(infoElement).toHaveTextContent(tab.info);
}
if (tab.icon) {
expect(screen.getAllByTestId("icon-component")).toHaveLength(3);
}
});
expect(externalLink.length).toEqual(1);
expect(iconElement.length).toEqual(1);
// Check sticky behavior
await expect(container.firstChild).toHaveClass("sticky");
});
test("applies custom icon correctly", async () => {
render(
<VerticalTabs
tabs={[
{
name: "Overview",
href: "/overview",
icon: "atom",
info: "Main dashboard view",
},
]}
className="custom-nav"
itemClassname="custom-item"
iconClassName="custom-icon"
/>
);
const iconElement = screen.getByTestId("icon-component");
expect(iconElement).toBeInTheDocument();
await expect(iconElement).toHaveClass("custom-icon");
});
test("applies custom classNames correctly", async () => {
render(
<VerticalTabs
tabs={[
{
name: "Overview",
href: "/overview",
icon: "atom",
info: "Main dashboard view",
"data-testid": "overview",
},
]}
className="custom-nav"
itemClassname="custom-item"
iconClassName="custom-icon"
/>
);
const nav = screen.getByTestId("vertical-tab-overview").closest("nav");
await expect(nav).toHaveClass("custom-nav");
const tabElement = screen.getByTestId("vertical-tab-overview");
await expect(tabElement).toHaveClass("custom-item");
const iconElement = screen.getByTestId("icon-component");
await expect(iconElement).toHaveClass("custom-icon");
});
});
});
@@ -0,0 +1,103 @@
"use client";
import { useState } from "react";
import { Button } from "../button";
import { ButtonGroup } from "../buttonGroup";
import { Select } from "../form/select";
export interface PaginationProps {
currentPage: number;
pageSize: number;
totalItems: number;
onPageChange: (page: number) => void;
onPageSizeChange: (pageSize: number) => void;
onNext?: () => void;
onPrevious?: () => void;
pageSizeOptions?: number[];
}
const DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100];
export const Pagination = ({
currentPage,
pageSize,
totalItems,
onPageChange,
onPageSizeChange,
pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,
onNext,
onPrevious,
}: PaginationProps) => {
const [internalPageSize, setInternalPageSize] = useState(pageSize);
const totalPages = Math.ceil(totalItems / pageSize);
const handlePageSizeChange = (option: { value: number; label: string } | null) => {
if (option) {
const newPageSize = option.value;
setInternalPageSize(newPageSize);
onPageSizeChange(newPageSize);
// Reset to first page when changing page size
onPageChange(1);
}
};
const handlePrevious = () => {
if (currentPage > 1) {
onPageChange(currentPage - 1);
onPrevious?.();
}
};
const handleNext = () => {
if (currentPage < totalPages) {
onPageChange(currentPage + 1);
onNext?.();
}
};
const pageSizeSelectOptions = pageSizeOptions.map((size) => ({
value: size,
label: `${size}`,
}));
const startItem = (currentPage - 1) * pageSize + 1;
const endItem = Math.min(currentPage * pageSize, totalItems);
return (
<div className="flex items-center justify-between space-x-2 py-4">
<div className="flex items-center space-x-2">
<Select
options={pageSizeSelectOptions}
value={pageSizeSelectOptions.find((option) => option.value === internalPageSize)}
onChange={handlePageSizeChange}
size="sm"
/>
<span className="text-default text-sm">rows per page</span>
</div>
<div className="flex items-center space-x-2">
<span className="text-default text-sm">
{startItem}-{endItem} of {totalItems}
</span>
<ButtonGroup containerProps={{ className: "space-x-1.5" }}>
<Button
variant="icon"
StartIcon="arrow-left"
onClick={handlePrevious}
disabled={currentPage <= 1}
color="secondary"
size="sm"
/>
<Button
variant="icon"
StartIcon="arrow-right"
onClick={handleNext}
disabled={currentPage >= totalPages}
color="secondary"
size="sm"
/>
</ButtonGroup>
</div>
</div>
);
};
@@ -0,0 +1,2 @@
export { Pagination } from "./Pagination";
export type { PaginationProps } from "./Pagination";
@@ -3,6 +3,7 @@ import React from "react";
import { classNames } from "@calcom/lib";
import { buttonClasses } from "../button";
import { Icon } from "../icon";
import { Tooltip } from "../tooltip";
@@ -29,7 +30,8 @@ export const AnimatedPopover = ({
const ref = React.useRef<HTMLButtonElement>(null);
// calculate which aligment to open the popover with based on which half of the screen it is on (left or right)
const [align, setAlign] = React.useState<"start" | "end">("start");
React.useEffect(() => {
React.useLayoutEffect(() => {
const handleResize = () => {
const halfWidth = window.innerWidth / 2;
const { x } = ref?.current?.getBoundingClientRect() || {
@@ -55,7 +57,9 @@ export const AnimatedPopover = ({
<button
ref={ref}
className={classNames(
"hover:border-emphasis border-default text-default hover:text-emphasis radix-state-open:border-emphasis radix-state-open:outline-none radix-state-open:ring-2 radix-state-open:ring-emphasis mb-4 flex h-9 max-h-72 items-center justify-between whitespace-nowrap rounded-md border px-3 py-2 text-sm hover:cursor-pointer",
buttonClasses({
color: "secondary",
}),
popoverTriggerClassNames
)}>
{Trigger ? (
@@ -63,7 +67,7 @@ export const AnimatedPopover = ({
) : (
<div className="max-w-36 flex items-center">
<Tooltip content={prefix ? `${prefix}${text}` : text}>
<div className="flex select-none truncate font-medium">
<div className="flex select-none items-center truncate font-medium leading-none">
{PrefixComponent ? PrefixComponent : null}
{prefix && <span className="text-subtle">{prefix}&nbsp;</span>}
{text}
+1 -1
View File
@@ -1 +1 @@
export { DefaultToast, ErrorToast, SuccessToast, WarningToast, showToast } from "./showToast";
export { ErrorToast, SuccessToast, WarningToast, showToast } from "./showToast";
+16 -23
View File
@@ -14,64 +14,57 @@ type IToast = {
export const SuccessToast = ({ message, toastVisible, onClose, toastId }: IToast) => (
<button
className={classNames(
"data-testid-toast-success bg-brand-default text-brand mb-2 flex h-auto space-x-2 rounded-md p-3 text-sm font-semibold shadow-md rtl:space-x-reverse md:max-w-sm",
"data-testid-toast-success bg-default dark:bg-inverted text-emphasis dark:text-inverted shadow-elevation-low border-subtle mb-2 flex h-auto space-x-2 rounded-lg border px-3 py-2.5 text-sm font-semibold rtl:space-x-reverse md:max-w-sm",
toastVisible && "animate-fade-in-up cursor-pointer"
)}
onClick={() => onClose(toastId)}>
<span className="mt-0.5">
<Icon name="check" className="h-4 w-4" />
</span>
<p data-testid="toast-success" className="text-left">
<p data-testid="toast-success" className="m-0 w-full text-left">
{message}
</p>
<span className="mt-0.5">
<Icon name="x" className="h-4 w-4 hover:cursor-pointer" />
</span>
</button>
);
export const ErrorToast = ({ message, toastVisible, onClose, toastId }: IToast) => (
<button
className={classNames(
"animate-fade-in-up bg-error text-error text-brand mb-2 flex h-auto space-x-2 rounded-md p-3 text-sm font-semibold shadow-md rtl:space-x-reverse md:max-w-sm",
"animate-fade-in-up bg-semantic-error-subtle text-semantic-error shadow-elevation-low border-semantic-error-subtle mb-2 flex h-auto space-x-2 rounded-md border px-3 py-2.5 text-sm font-semibold rtl:space-x-reverse md:max-w-sm",
toastVisible && "animate-fade-in-up cursor-pointer"
)}
onClick={() => onClose(toastId)}>
<span className="mt-0.5">
<Icon name="info" className="h-4 w-4" />
<Icon name="info" className="text-semantic-error h-4 w-4" />
</span>
<p data-testid="toast-error" className="text-left">
<p data-testid="toast-error" className="m-0 w-full text-left">
{message}
</p>
<span className="mt-0.5">
<Icon name="x" className="text-semantic-error h-4 w-4 hover:cursor-pointer" />
</span>
</button>
);
export const WarningToast = ({ message, toastVisible, onClose, toastId }: IToast) => (
<button
className={classNames(
"animate-fade-in-up bg-brand-default text-brand mb-2 flex h-auto space-x-2 rounded-md p-3 text-sm font-semibold shadow-md rtl:space-x-reverse md:max-w-sm",
"animate-fade-in-up bg-semantic-attention-subtle text-semantic-attention shadow-elevation-low border-semantic-attention-subtle mb-2 flex h-auto space-x-2 rounded-md border px-3 py-2.5 text-sm font-semibold rtl:space-x-reverse md:max-w-sm",
toastVisible && "animate-fade-in-up cursor-pointer"
)}
onClick={() => onClose(toastId)}>
<span className="mt-0.5">
<Icon name="info" className="h-4 w-4" />
<Icon name="info" className="text-semantic-attention h-4 w-4" />
</span>
<p data-testid="toast-warning" className="text-left">
<p data-testid="toast-warning" className="m-0 w-full text-left">
{message}
</p>
</button>
);
export const DefaultToast = ({ message, toastVisible, onClose, toastId }: IToast) => (
<button
className={classNames(
"animate-fade-in-up bg-brand-default text-brand mb-2 flex h-auto space-x-2 rounded-md p-3 text-sm font-semibold shadow-md rtl:space-x-reverse md:max-w-sm",
toastVisible && "animate-fade-in-up cursor-pointer"
)}
onClick={() => onClose(toastId)}>
<span className="mt-0.5">
<Icon name="check" className="h-4 w-4" />
<Icon name="x" className="text-semantic-attention h-4 w-4 hover:cursor-pointer" />
</span>
<p data-testid="toast-default" className="text-left">
{message}
</p>
</button>
);
@@ -104,7 +97,7 @@ export function showToast(
};
return toast.custom(
toastElements[variant] ||
((t) => <DefaultToast message={message} toastVisible={t.visible} onClose={onClose} toastId={t.id} />),
((t) => <SuccessToast message={message} toastVisible={t.visible} onClose={onClose} toastId={t.id} />),
_options
);
}
Loaded 100 of 145 files, more files were not shown because too many files have changed in this diff. Show more