feat: upgrade tailwind v4 (#24598)

* chore: refactor config files to prevent migration tool errors

* refactor: upgrade with the tailwind migration tool

* chore: restore pre-commit command + mc

* refactor(wip): update dependencies and migrate to Tailwind CSS v4 (mainly web)

* chore: resolve Tailwind v4 migration conflicts from merging main

* chore: remove unused Tailwind packages from config and update dependencies for v4 migration

* chore: uncomment Tailwind CSS utility classes in globals.css

* fix: resolve token conflicts between calcom and coss ui

* fix: textarea scrollbar

* Fix CUI-16

* fix: added @tailwindcss/forms plugin and cleaned up CSS classes in various components to remove unnecessary dark mode styles

* fix: selects and inputs of different sizes

* fix: remove unnecessary leading-20 class from modal titles in various components

* fix: update Checkbox component styles to remove unnecessary border on checked state

* fix: clean up styles in RequiresConfirmationController, Checkbox, and Radio components to enhance consistency

* fix: update button and filter component styles to remove unnecessary rounded classes for consistency

* fix: calendar

* fix: update KBarSearch

* fix: refine styles in Empty and Checkbox components for improved consistency

* Fix focus state email input

* fix: update button hover and active states to use 'not-disabled' instead of 'enabled'

* fix: line-height issues

* fix: update class name for muted background in BookingListItem component

* fix: sidebar spacing

* chore: update class names to use new Tailwind CSS color utilities

* fix embed

* chore: upgrade Tailwind CSS to version 4.1.16 and update related dependencies

* Map css variables and add a playground test for heavy css customization

* suggestion for coss-ui

* refactor: update CSS variable usage and clean up styles

- Replace instances of `--cal-brand-color` with `--cal-brand` in embed-related HTML files.
- Remove the now-unnecessary `addAppCssVars` function from the embed core.
- Import theme tokens in the embed core styles for better consistency.
- Clean up whitespace and formatting in CSS files for improved readability.
- Add a comment in `tokens.css` regarding its usage in both embed and webapp contexts.

* Handle within tokens.css instead of fixing coss-ui

* Remove initial, not needed. Also, remove tailwind.config.js as tailwidn scans the html automaically

* fix: examples app breaking

* fix: modal not resizing correctly

* feat: upgrade atoms to tailwind v4

* fix: atoms build breaking

* fix: atoms build breaking

* chore: upgrate examples/base to tailwind 4

* chore: update globals.css

* fix: add missing scheduler css variables

* fix: PlatformAdditionalCalendarSelector

* chore: update global styles

* chore: update tailwindcss and postcss dependencies to stable versions

* chore: remove unneeded class

* fix: dialog and toast animation

* fix: replace flex-shrink-0 with shrink-0 for consistent styling in various components

* fix: dialog modal for Apple connect

* add margin in SaveFilterSegmentButton

* Fix radix button nested states

* add cursor pointer to buttons but keep dsabled state

* Fix commandK selectors and adds cursor pointer

* Fix teams filter

* fix - round checkboxes

* fix filter checkbox

* fix select indicator's margin

* command group font size

* style: fix badge and tooltip radius

* chore: remove unneeded files

* Delete PR_REVIEW_MANAGED_EVENT_REASSIGNMENT.md

* remove ui-playground leftover

* fix: add missing react phone input styles in atoms

* Delete managed-event-reassignment-flow-and-architecture.mermaid

* fix: inter font not loading

* Add theme to skeleton container so that it can support dark mode

* fix: create custom stack-y-* utilities post tw4 upgrade

* fix: typo

* fix: atoms stack class + remove unused css file

* fix default radius valiue

* fix space-y in embed

* fix skeleton background

* Hardcode radius values to match production

* fix border in embed

* add missing externalThemeClass

* feat: create a custom stack-y-* utility

* fix: add stack utility to atom global css

* fix: Skeleton loader class modalbox

* Add stack-y utility in embed

* fix: add missing stack utilities in atoms globals.css

* update yarn.lock

* add popover portla

* update

---------

Co-authored-by: Sean Brydon <[email protected]>
Co-authored-by: Hariom Balhara <[email protected]>
Co-authored-by: Ryukemeister <[email protected]>
Co-authored-by: cal.com <[email protected]>
Co-authored-by: Eunjae Lee <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-11-25 17:32:28 -03:00
1 parent 625c260e40
commit d6546c3107
447 files changed
+14783 -28932

No files matched your search

@@ -78,6 +78,7 @@ function createTestEmbedElement(data: {
element.innerHTML = inlineHTML({
layout: dataset?.layout,
pageType: dataset?.pageType as EmbedPageType | null,
externalThemeClass: dataset?.theme === "dark" ? EMBED_DARK_THEME_CLASS : EMBED_LIGHT_THEME_CLASS,
});
document.body.appendChild(element);
@@ -132,7 +133,6 @@ function mockGetComputedStyle() {
describe("EmbedElement", () => {
let element: EmbedElement;
let mockGetSkeletonData: Mock;
beforeEach(() => {
// Register the custom element
@@ -8,7 +8,7 @@ import {
addDarkColorSchemeChangeListener,
getMaxHeightForModal,
} from "./ui-utils";
import type { ExternalThemeClass } from "./ui/themeClass";
type ShadowRootWithStyle = ShadowRoot & {
host: HTMLElement & { style: CSSStyleDeclaration };
};
@@ -19,7 +19,7 @@ export class EmbedElement extends HTMLElement {
public isModal!: boolean;
public skeletonContainerHeightTimer: number | null = null;
// Theme Class is derived from `this.theme` as well as system color scheme preference
public themeClass!: string;
public themeClass!: ExternalThemeClass;
public layout!: AllPossibleLayouts;
public getSkeletonData!: (_args: { layout: AllPossibleLayouts; pageType: EmbedPageType | null }) => {
skeletonContent: string;
@@ -11,7 +11,7 @@ const getHtml = ({
}) => {
// IT IS A REQUIREMENT THAT ALL POSSIBLE CLASSES ARE HERE OTHERWISE TAILWIND WONT GENERATE THE CSS FOR CONDITIONAL CLASSES
// To not let all these classes apply and visible, keep it hidden initially
return `<button class="z-[999999999999] hidden fixed md:bottom-6 bottom-4 md:right-10 right-4 md:left-10 left-4 ${buttonClasses.join(
return `<button class="z-999999999999 hidden fixed md:bottom-6 bottom-4 md:right-10 right-4 md:left-10 left-4 ${buttonClasses.join(
" "
)} flex h-16 origin-center bg-red-50 transform cursor-pointer items-center
rounded-full py-4 px-6 text-base outline-none drop-shadow-md transition focus:outline-none fo
@@ -2,7 +2,6 @@ import { EmbedElement } from "../EmbedElement";
import { getErrorString } from "../lib/utils";
import loaderCss from "../loader.css?inline";
import inlineHtml, { getSkeletonData } from "./inlineHtml";
export class Inline extends EmbedElement {
static get observedAttributes() {
return ["loading"];
@@ -38,6 +37,7 @@ export class Inline extends EmbedElement {
this.shadowRoot.innerHTML = `<style>${window.Cal.__css}</style><style>${loaderCss}</style>${inlineHtml({
layout: this.layout,
pageType: this.getPageType() ?? null,
externalThemeClass: this.themeClass
})}`;
}
}
@@ -1,20 +1,23 @@
import type { AllPossibleLayouts, EmbedPageType } from "../types";
import { generateSkeleton } from "../ui/skeleton";
import { type ExternalThemeClass, getInternalThemeClass } from "../ui/themeClass";
const html = ({
layout = "month_view",
pageType,
externalThemeClass,
}: {
layout?: AllPossibleLayouts;
pageType: EmbedPageType | null;
externalThemeClass: ExternalThemeClass;
}) => {
const { skeletonContent, skeletonContainerStyle, skeletonStyle } = getSkeletonData({
layout,
pageType,
});
const themeClass = getInternalThemeClass(externalThemeClass);
return `
<div id="skeleton-container" style="${skeletonContainerStyle}">
<div id="skeleton-container" style="${skeletonContainerStyle}" ${themeClass ? `class="${themeClass}"` : ""}>
<div id="skeleton" style="${skeletonStyle}" class="absolute z-highest">
${skeletonContent}
</div>
@@ -175,9 +175,9 @@ export class ModalBox extends EmbedElement {
const message = this.dataset.message;
const errorMessage = this.dataset.errorCode
? getErrorString({
errorCode: this.dataset.errorCode,
errorMessage: message,
})
errorCode: this.dataset.errorCode,
errorMessage: message,
})
: null;
const messageToShow = errorMessage || message;
if (messageToShow) {
@@ -250,6 +250,7 @@ export class ModalBox extends EmbedElement {
const modalHtml = `<style>${window.Cal.__css}</style><style>${loaderCss}</style>${modalBoxHtml({
layout: this.getLayout(),
pageType: this.getPageType() ?? null,
externalThemeClass: this.themeClass
})}`;
this.attachShadow({ mode: "open" });
ModalBox.htmlOverflow = document.body.style.overflow;
@@ -1,5 +1,6 @@
import type { AllPossibleLayouts, EmbedPageType } from "../types";
import { generateSkeleton } from "../ui/skeleton";
import { type ExternalThemeClass, getInternalThemeClass } from "../ui/themeClass";
function getStyle() {
return `
@@ -56,7 +57,7 @@ function getStyle() {
}
/*Modal background is black only, so hardcode white */
.loader {
--cal-brand-color:white;
--cal-brand:white;
}
</style>
`;
@@ -65,15 +66,19 @@ function getStyle() {
const html = ({
layout = "month_view",
pageType,
externalThemeClass,
}: {
layout?: AllPossibleLayouts;
pageType: EmbedPageType | null;
externalThemeClass: ExternalThemeClass;
}) => {
const { skeletonContent, skeletonContainerStyle, skeletonStyle } = getSkeletonData({
layout,
pageType,
});
const themeClass = getInternalThemeClass(externalThemeClass);
// Keep message-container outside modal-box as that restricts the content to be shown through its overflow:auto unnecessarily
return `
${getStyle()}
@@ -81,12 +86,12 @@ ${getStyle()}
<div class="header">
<button type="button" class="close" aria-label="Close">&times;</button>
</div>
<div id="message-container" style="left: 50%; top: 50%; transform: translate(-50%, -50%);" class="message-container flex items-center p-24 justify-center dark:bg-muted rounded-md border-subtle border bg-default text-default absolute z-highest">
<div id="message-container" style="left: 50%; top: 50%; transform: translate(-50%, -50%);" class="message-container flex items-center p-24 justify-center dark:bg-cal-muted rounded-md border-subtle border bg-default text-default absolute z-highest">
<div id="message"></div>
</div>
<div class="modal-box">
<div class="body" id="skeleton-container" style="${skeletonContainerStyle}">
<div id="wrapper" class="z-[999999999999] absolute flex w-full items-center">
<div class="body${themeClass ? " " + themeClass : ""}" id="skeleton-container" style="${skeletonContainerStyle}">
<div id="wrapper" class="z-999999999999 absolute flex w-full items-center">
<div class="loader modal-loader border-brand-default dark:border-darkmodebrand">
<span class="loader-inner bg-brand dark:bg-darkmodebrand"></span>
</div>
@@ -1,260 +0,0 @@
import { EMBED_DARK_THEME_CLASS } from "./constants";
export const addAppCssVars = () => {
const calElements = ["cal-floating-button", "cal-modal-box", "cal-inline"];
try {
const cssVarsStyle = `
${calElements.join(",")} {
/* 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 */
}
${calElements.map((element) => `${element}.${EMBED_DARK_THEME_CLASS}`).join(",")} {
/* Background Standard */
--cal-bg-emphasis: hsla(0, 0%, 25%, 1); /* stone-700 */
--cal-bg: hsla(0, 0%, 6%, 1); /* stone-950 */
--cal-bg-subtle: hsla(0, 0%, 15%, 1); /* stone-800 */
--cal-bg-muted: hsla(0, 0%, 9%, 1); /* stone-900 */
--cal-bg-inverted: hsla(0, 0%, 98%, 1); /* stone-50 */
/* Background Primary */
--cal-bg-primary: hsla(0, 0%, 96%, 1); /* stone-100 */
--cal-bg-primary-emphasis: hsla(0, 0%, 64%, 1); /* stone-800 */
--cal-bg-primary-muted: hsla(0, 0%, 15%, 1); /* stone-400 */
/* Background Brand */
--cal-bg-brand: hsla(0, 0%, 98%, 1); /* gray-50 */
--cal-bg-brand-emphasis: hsla(0, 0%, 96%, 1); /* stone-100 */
--cal-bg-brand-muted: hsla(0, 0%, 96%, 1); /* stone-100 */
/* Background Semantic */
--cal-bg-semantic-info-subtle: hsla(236, 80%, 8%, 1); /* blue-800 */
--cal-bg-semantic-info-emphasis: hsla(229, 90%, 74%, 1); /* blue-500 */
--cal-bg-semantic-success-subtle: hsla(148, 88%, 16%, 1); /* green-800 */
--cal-bg-semantic-success-emphasis: hsla(158, 74%, 38%, 1); /* green-500 */
--cal-bg-semantic-attention-subtle: hsla(21, 86%, 8%, 1); /* orange-800 */
--cal-bg-semantic-attention-emphasis: hsla(27, 96%, 61%, 1); /* orange-500 */
--cal-bg-semantic-error-subtle: hsla(0, 70%, 8%, 1); /* red-800 */
--cal-bg-semantic-error-emphasis: hsla(0, 91%, 71%, 1); /* red-500 */
/* Background Visualization */
--cal-bg-visualization-1-subtle: hsla(336, 74%, 35%, 1); /* pink-200 */
--cal-bg-visualization-1-emphasis: hsla(330, 81%, 60%, 1); /* pink-500 */
--cal-bg-visualization-2-subtle: hsla(252, 83%, 23%, 1); /* purple-200 */
--cal-bg-visualization-2-emphasis: hsla(256, 85%, 57%, 1); /* purple-500 */
--cal-bg-visualization-3-subtle: hsla(236, 74%, 35%, 1); /* blue-200 */
--cal-bg-visualization-3-emphasis: hsla(235, 100%, 63%, 1); /* blue-500 */
--cal-bg-visualization-4-subtle: hsla(150, 84%, 22%, 1); /* green-200 */
--cal-bg-visualization-4-emphasis: hsla(158, 74%, 38%, 1); /* green-500 */
--cal-bg-visualization-5-subtle: hsla(28, 73%, 26%, 1); /* yellow-200 */
--cal-bg-visualization-5-emphasis: hsla(45, 93%, 47%, 1); /* yellow-500 */
--cal-bg-visualization-6-subtle: hsla(15, 75%, 23%, 1); /* orange-200 */
--cal-bg-visualization-6-emphasis: hsla(25, 95%, 53%, 1); /* orange-500 */
--cal-bg-visualization-7-subtle: hsla(0, 70%, 35%, 1); /* red-200 */
--cal-bg-visualization-7-emphasis: hsla(0, 84%, 60%, 1); /* red-500 */
/* Legacy Background Components - Consider deprecating */
--cal-bg-info: hsla(228, 56%, 33%, 1); /* Keeping existing info background */
--cal-bg-success: hsla(133, 34%, 24%, 1); /* Keeping existing success background */
--cal-bg-attention: hsla(16, 62%, 28%, 1); /* Keeping existing attention background */
--cal-bg-error: hsla(2, 55%, 30%, 1); /* Keeping existing error background */
--cal-bg-dark-error: hsla(2, 55%, 30%, 1); /* Keeping existing dark error */
/* Border Standard */
--cal-border: hsla(0, 0%, 30%, 1); /* stone-600 */
--cal-border-muted: hsla(0, 0%, 9%, 1); /* stone-500 */
--cal-border-subtle: hsla(0, 0%, 15%, 1); /* stone-700 */
--cal-border-emphasis: hsla(0, 0%, 45%, 1); /* stone-800 */
--cal-border-booker: var(--cal-border-subtle);
/* Border Semantic */
--cal-border-semantic-error: hsla(0, 63%, 24%, 1); /* red-800 */
/* Border/Semantic Subtle */
--cal-border-semantic-attention-subtle: hsla(15, 75%, 23%, 1);
--cal-border-semantic-error-subtle: hsla(0, 63%, 24%, 1);
/* Legacy Border - Consider deprecating */
--cal-border-error: hsla(0, 63%, 24%, 1); /* Keeping existing error border */
/* Content/Text Standard */
--cal-text-emphasis: hsla(0, 0%, 98%, 1); /* stone-50 */
--cal-text: hsla(0, 0%, 83%, 1); /* stone-300 */
--cal-text-subtle: hsla(0, 0%, 64%, 1); /* stone-400 */
--cal-text-muted: hsla(0, 0%, 64%, 1); /* stone-400 */
--cal-text-inverted: hsla(0, 0%, 0%, 1); /* black */
/* Content/Text Semantic */
--cal-text-semantic-info: hsla(229, 90%, 74%, 1); /* blue-100 */
--cal-text-semantic-success: hsla(161, 49%, 54%, 1); /* green-100 */
--cal-text-semantic-attention: hsla(27, 96%, 61%, 1); /* orange-100 */
--cal-text-semantic-error: hsla(0, 91%, 71%, 1); /* red-100 */
/* Content/Text Semantic Emphasis */
--cal-text-semantic-info-emphasis: hsla(217, 91%, 25%, 1); /* blue-800 */
--cal-text-semantic-success-emphasis: hsla(142, 71%, 25%, 1); /* green-800 */
--cal-text-semantic-attention-emphasis: hsla(24, 95%, 25%, 1); /* orange-800 */
--cal-text-semantic-error-emphasis: hsla(0, 84%, 25%, 1); /* red-800 */
/* Legacy Content/Text Components - Consider deprecating */
--cal-text-info: hsla(218, 83%, 93%, 1); /* Keeping existing info text */
--cal-text-success: hsla(134, 76%, 94%, 1); /* Keeping existing success text */
--cal-text-attention: hsla(37, 86%, 92%, 1); /* Keeping existing attention text */
--cal-text-error: hsla(3, 66%, 93%, 1); /* Keeping existing error text */
/* Brand */
--cal-brand: hsla(0, 0%, 100%, 1); /* white */
--cal-brand-emphasis: hsla(218, 11%, 65%, 1); /* Keeping existing brand emphasis */
--cal-brand-text: hsla(0, 0%, 0%, 1); /* black */
}
`;
// 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);
}
};
+26 -2
View File
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useRef, useState, useCallback } from "react";
import { mapOldToNewCssVars } from "./ui/cssVarsMap";
import type { Message } from "./embed";
import { embedStore, EMBED_IFRAME_STATE } from "./embed-iframe/lib/embedStore";
import {
@@ -348,6 +348,7 @@ async function waitForRenderStateToBeCompleted() {
});
}
// It is a map of methods that can be called by parent using doInIframe({method: "methodName", arg: "argument"})
export const methods = {
ui: function style(uiConfig: UiConfig) {
@@ -374,13 +375,36 @@ export const methods = {
}
// Merge new values over the old values
// For cssVarsPerTheme, we need to merge at the theme level to preserve variables from both old and new configs
const oldCssVarsPerTheme = embedStore.uiConfig?.cssVarsPerTheme;
const newCssVarsPerTheme = uiConfig.cssVarsPerTheme;
let mergedCssVarsPerTheme: UiConfig["cssVarsPerTheme"] | undefined;
if (oldCssVarsPerTheme || newCssVarsPerTheme) {
mergedCssVarsPerTheme = {} as Record<"light" | "dark", Record<string, string>>;
const themeKeys = [
...(oldCssVarsPerTheme ? Object.keys(oldCssVarsPerTheme) : []),
...(newCssVarsPerTheme ? Object.keys(newCssVarsPerTheme) : []),
];
const themes = Array.from(new Set(themeKeys)) as Array<"light" | "dark">;
for (const theme of themes) {
mergedCssVarsPerTheme[theme] = {
...oldCssVarsPerTheme?.[theme],
...newCssVarsPerTheme?.[theme],
};
}
}
uiConfig = {
...embedStore.uiConfig,
...uiConfig,
...(mergedCssVarsPerTheme ? { cssVarsPerTheme: mergedCssVarsPerTheme } : {}),
};
if (uiConfig.cssVarsPerTheme) {
window.CalEmbed.applyCssVars(uiConfig.cssVarsPerTheme);
const mappedCssVarsPerTheme = mapOldToNewCssVars(uiConfig.cssVarsPerTheme);
window.CalEmbed.applyCssVars(mappedCssVarsPerTheme);
}
if (uiConfig.colorScheme) {
+13 -16
View File
@@ -2,7 +2,6 @@
import { FloatingButton } from "./FloatingButton/FloatingButton";
import { Inline } from "./Inline/inline";
import { ModalBox } from "./ModalBox/ModalBox";
import { addAppCssVars } from "./addAppCssVars";
import {
EMBED_MODAL_IFRAME_FORCE_RELOAD_THRESHOLD_MS,
EMBED_MODAL_IFRAME_SLOT_STALE_TIME,
@@ -39,8 +38,6 @@ export type Message = {
// HACK: Redefine and don't import WEBAPP_URL as it causes import statement to be present in built file.
// This is happening because we are not able to generate an App and a lib using single Vite Config.
const WEBAPP_URL = process.env.EMBED_PUBLIC_WEBAPP_URL || `https://${process.env.EMBED_PUBLIC_VERCEL_URL}`;
// Add App CSS Vars as soon as possible so that tailwind classes can work instantly.
addAppCssVars();
customElements.define("cal-modal-box", ModalBox);
customElements.define("cal-floating-button", FloatingButton);
@@ -180,8 +177,8 @@ type SingleInstructionMap = {
off: ["off", allPossibleCallbacksAndActions];
} & {
[K in Exclude<keyof CalApi, "on" | "off">]: CalApi[K] extends (...args: never[]) => void
? [K, ...Parameters<CalApi[K]>]
: never;
? [K, ...Parameters<CalApi[K]>]
: never;
};
type SingleInstruction = SingleInstructionMap[keyof SingleInstructionMap];
@@ -602,7 +599,7 @@ export class Cal {
: 0;
const crossedReloadThreshold = previousEmbedRenderStartTime
? timeSinceLastRender >
(prerenderOptions?.iframeForceReloadThresholdMs ?? EMBED_MODAL_IFRAME_FORCE_RELOAD_THRESHOLD_MS)
(prerenderOptions?.iframeForceReloadThresholdMs ?? EMBED_MODAL_IFRAME_FORCE_RELOAD_THRESHOLD_MS)
: false;
const areSlotsStale = previousEmbedRenderStartTime
@@ -948,10 +945,10 @@ class CalApi {
template.innerHTML = `<cal-inline
${generateDataAttributes({
pageType,
theme,
layout,
})}
pageType,
theme,
layout,
})}
style="max-height:inherit;height:inherit;min-height:inherit;display:flex;position:relative;flex-wrap:wrap;width:100%">
</cal-inline>
<style>.cal-inline-container::-webkit-scrollbar{display:none}.cal-inline-container{scrollbar-width:none}</style>`;
@@ -1191,8 +1188,8 @@ class CalApi {
...enrichedConfig,
...(actionToTake === "connect-no-slots-fetch"
? {
"cal.embed.noSlotsFetchOnConnect": "true",
}
"cal.embed.noSlotsFetchOnConnect": "true",
}
: {}),
},
params: paramsToAdd,
@@ -1234,10 +1231,10 @@ class CalApi {
template.innerHTML = `<cal-modal-box
${generateDataAttributes({
pageType,
theme,
layout,
})}
pageType,
theme,
layout,
})}
uid="${uid}">
</cal-modal-box>`;
this.cal.modalBox = template.content.children[0];
+14 -3
View File
@@ -1,6 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@import 'tailwindcss';
@import "@coss/ui/styles.css";
@import "../../../config/theme/tokens.css";
@font-face {
font-family: "Cal Sans";
src: url("https://cal.com/cal.ttf");
@@ -22,4 +23,14 @@ body,
:host {
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue,
Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
/** Tailwind defines this as @property and these are completely ignored if defined inside shadow DOM. - https://stackoverflow.com/questions/78717295/property-not-recognized-in-shadow-dom */
/** We avoid loading tailwind outside the shadow DOM as it could potentially affect the user's webpage. So define --tw prefixed properties here as and when used for now */
--tw-border-style: solid;
}
@utility stack-y-* {
&> :not([hidden])~ :not([hidden]) {
margin-top: --spacing(--value(integer));
margin-top: --value([length]);
}
}
@@ -0,0 +1,61 @@
import { UiConfig } from "../types";
/**
* Maps old CSS variable names to new Tailwind v4 variable names.
* This maintains backward compatibility by allowing users to use old variable names
* while the webapp uses the new Tailwind v4 format.
*
* This is only applicable as long as fundamentally the purpose of the variable is the same.
* In some cases, we have special classes designed to target specific elements e.g. border-booker class which is configured to use variable --cal-border-booker.
* In those special cases, we need to ensure that we don't remove those special css variables. Renaming them is fine and in which case we would need to map them here.
*
*/
const OLD_TO_NEW_CSS_VAR_MAP: Record<string, string> = {
// Border radius variables: --cal-radius-* -> --radius-*
"cal-radius": "radius",
"cal-radius-sm": "radius-sm",
"cal-radius-md": "radius-md",
"cal-radius-lg": "radius-lg",
"cal-radius-xl": "radius-xl",
"cal-radius-2xl": "radius-2xl",
"cal-radius-3xl": "radius-3xl",
"cal-radius-full": "radius-full",
"cal-radius-none": "radius-none",
// We don't intentionally want to support all spacing variables, from just one variable our design system derives all the rest.
"cal-spacing-px": "spacing",
// No need to map the following
// Colors - Still using the old variable names --cal-bg-* and --cal-brand-*
// Border colors - Still using the old variable names --cal-border-*
// text colors - Still using the old variable names --cal-text-*
// fill colors - Still using the old variable names --cal-fill-*
};
/**
* Transforms cssVarsPerTheme by mapping old CSS variable names to new Tailwind v4 names.
* This ensures backward compatibility while the webapp uses the new variable format.
*/
export function mapOldToNewCssVars(
cssVarsPerTheme: UiConfig["cssVarsPerTheme"]
): UiConfig["cssVarsPerTheme"] {
if (!cssVarsPerTheme) {
return cssVarsPerTheme;
}
const mapped: Record<string, Record<string, string>> = {};
for (const [theme, cssVars] of Object.entries(cssVarsPerTheme)) {
mapped[theme] = {};
for (const [varName, value] of Object.entries(cssVars)) {
// If the variable name exists in the mapping, use the new name; otherwise keep the original
const newVarName = OLD_TO_NEW_CSS_VAR_MAP[varName];
if (!newVarName) {
mapped[theme][varName] = value
continue;
}
console.log("Mapped variable:", varName, "to", newVarName);
mapped[theme][newVarName] = value;
}
}
return mapped as UiConfig["cssVarsPerTheme"];
}
@@ -28,7 +28,7 @@ const generateEventMetaSkeleton = () => {
<h1 data-testid="event-title" class="text-text text-xl font-semibold my-2 mb-4">
<div class="animate-pulse bg-emphasis h-6 w-20 rounded-sm"></div>
</h1>
<div class="space-y-3 font-medium">
<div class="stack-y-3 font-medium">
${eventMetaOptions}
</div>
</div>
@@ -73,7 +73,7 @@ const generateDatePickerSkeleton = () => {
for (let i = 1; i <= daysInMonth; i++) {
dates += `
<div class="relative w-full pt-[100%]">
<button class="bg-muted text-muted absolute bottom-0 left-0 right-0 top-0 mx-auto flex w-full items-center justify-center rounded-sm border-transparent text-center font-medium opacity-90 transition" disabled="">
<button class="bg-cal-muted text-muted absolute bottom-0 left-0 right-0 top-0 mx-auto flex w-full items-center justify-center rounded-sm border-transparent text-center font-medium opacity-90 transition" disabled="">
<span class="font-size-0 bg-emphasis inline-block animate-pulse rounded-md empty:before:inline-block empty:before:content-[''] h-9 w-9"></span>
</button>
</div>`;
@@ -101,13 +101,13 @@ const generateDatePickerSkeleton = () => {
</span>
<div class="text-emphasis">
<div class="flex">
<button class="group whitespace-nowrap items-center font-medium relative rounded-[10px] disabled:cursor-not-allowed gap-1 flex justify-center text-subtle border border-transparent enabled:hover:bg-subtle enabled:hover:text-emphasis enabled:hover:border-subtle hover:border disabled:opacity-30 focus-visible:bg-subtle focus-visible:outline-none focus-visible:ring-0 focus-visible:border-subtle focus-visible:shadow-button-outline-gray-focused enabled:active:shadow-outline-gray-active duration-200 text-sm leading-none min-h-[36px] min-w-[36px] !p-2 hover:border-default group p-1 opacity-70 transition hover:opacity-100 rtl:rotate-180" data-testid="decrementMonth" aria-label="View previous month" type="button" disabled>
<button class="group whitespace-nowrap items-center font-medium relative rounded-[10px] disabled:cursor-not-allowed gap-1 flex justify-center text-subtle border border-transparent enabled:hover:bg-subtle enabled:hover:text-emphasis enabled:hover:border-subtle hover:border disabled:opacity-30 focus-visible:bg-subtle focus-visible:outline-none focus-visible:ring-0 focus-visible:border-subtle focus-visible:shadow-button-outline-gray-focused enabled:active:shadow-outline-gray-active duration-200 text-sm leading-none min-h-[36px] min-w-[36px] p-2! hover:border-default group p-1 opacity-70 transition hover:opacity-100 rtl:rotate-180" data-testid="decrementMonth" aria-label="View previous month" type="button" disabled>
<svg height="16" width="16" class="fill-transparent visible button-icon group-active:translate-y-[0.5px] h-4 w-4" data-name="start-icon" aria-hidden="true">
<use href="#chevron-left"></use>
</svg>
<div class="contents visible group-active:translate-y-[0.5px]"></div>
</button>
<button class="group whitespace-nowrap items-center font-medium relative rounded-[10px] disabled:cursor-not-allowed gap-1 flex justify-center text-subtle border border-transparent enabled:hover:bg-subtle enabled:hover:text-emphasis enabled:hover:border-subtle hover:border disabled:opacity-30 focus-visible:bg-subtle focus-visible:outline-none focus-visible:ring-0 focus-visible:border-subtle focus-visible:shadow-button-outline-gray-focused enabled:active:shadow-outline-gray-active duration-200 text-sm leading-none min-h-[36px] min-w-[36px] !p-2 hover:border-default group p-1 opacity-70 transition hover:opacity-100 rtl:rotate-180 undefined" data-testid="incrementMonth" aria-label="View next month" type="button">
<button class="group whitespace-nowrap items-center font-medium relative rounded-[10px] disabled:cursor-not-allowed gap-1 flex justify-center text-subtle border border-transparent enabled:hover:bg-subtle enabled:hover:text-emphasis enabled:hover:border-subtle hover:border disabled:opacity-30 focus-visible:bg-subtle focus-visible:outline-none focus-visible:ring-0 focus-visible:border-subtle focus-visible:shadow-button-outline-gray-focused enabled:active:shadow-outline-gray-active duration-200 text-sm leading-none min-h-[36px] min-w-[36px] p-2! hover:border-default group p-1 opacity-70 transition hover:opacity-100 rtl:rotate-180 undefined" data-testid="incrementMonth" aria-label="View next month" type="button">
<svg height="16" width="16" class="fill-transparent visible button-icon group-active:translate-y-[0.5px] h-4 w-4" data-name="start-icon" aria-hidden="true">
<use href="#chevron-right"></use>
</svg>
@@ -130,18 +130,18 @@ const generateBookingSlotsPageSkeleton = ({ layout }: { layout: AllPossibleLayou
return `
<div
data-testid="booker-container"
class="[--booker-timeslots-width:240px] lg:[--booker-timeslots-width:280px] [--booker-main-width:480px] [--booker-meta-width:340px] lg:[--booker-meta-width:424px] bg-default dark:bg-muted grid max-w-full items-start dark:[color-scheme:dark] sm:transition-[width] sm:duration-300 sm:motion-reduce:transition-none md:flex-row border-subtle rounded-md"
class="[--booker-timeslots-width:240px] lg:[--booker-timeslots-width:280px] [--booker-main-width:480px] [--booker-meta-width:340px] lg:[--booker-meta-width:424px] bg-default dark:bg-cal-muted grid max-w-full items-start dark:scheme-dark sm:transition-[width] sm:duration-300 sm:motion-reduce:transition-none md:flex-row border-subtle rounded-md"
style="grid-template-areas: &quot;meta&quot; &quot;header&quot; &quot;main&quot; &quot;timeslots&quot;; width: 100%; grid-template-columns: 100%; grid-template-rows: minmax(min-content, max-content) 1fr; min-height: 0px; height: auto;">
<div
class="relative z-10 flex [grid-area:meta]">
<div class="[grid-area:meta] max-w-screen flex w-full flex-col md:w-[var(--booker-meta-width)]">
<div class="[grid-area:meta] max-w-screen flex w-full flex-col md:w-(--booker-meta-width)">
${generateEventMetaSkeleton()}
<div class="mt-auto px-5 py-3">
${generateDatePickerSkeleton()}
</div>
</div>
</div>
<div class="[grid-area:main] md:border-subtle ml-[-1px] h-full flex-shrink px-5 py-3 md:border-l lg:w-[var(--booker-main-width)]" style="opacity: 1; transform: none;">
<div class="[grid-area:main] md:border-subtle -ml-px h-full shrink px-5 py-3 md:border-l lg:w-(--booker-main-width)" style="opacity: 1; transform: none;">
</div>
</div>
`;
@@ -150,14 +150,14 @@ const generateBookingSlotsPageSkeleton = ({ layout }: { layout: AllPossibleLayou
return `
<div
data-testid="booker-container"
class="[--booker-timeslots-width:240px] lg:[--booker-timeslots-width:280px] [--booker-meta-width:240px] [--booker-main-width:480px] lg:[--booker-meta-width:280px] bg-default dark:bg-muted grid max-w-full items-start dark:[color-scheme:dark] sm:motion-reduce:transition-none md:flex-row rounded-md sm:transition-[width] sm:duration-300 border-subtle border undefined"
class="[--booker-timeslots-width:240px] lg:[--booker-timeslots-width:280px] [--booker-meta-width:240px] [--booker-main-width:480px] lg:[--booker-meta-width:280px] bg-default grid max-w-full items-start dark:scheme-dark sm:motion-reduce:transition-none md:flex-row rounded-md sm:transition-[width] sm:duration-300 border-subtle border undefined"
style="grid-template-areas: &quot;meta main main&quot; &quot;meta main main&quot;; width: calc(var(--booker-meta-width) + var(--booker-main-width)); grid-template-columns: var(--booker-meta-width) var(--booker-main-width); grid-template-rows: 1fr 0fr; min-height: 450px; height: auto;">
<div
class="relative z-10 flex [grid-area:meta]"
style="position: sticky; top: 0px;">
${generateEventMetaSkeleton()}
</div>
<div class="[grid-area:main] md:border-subtle ml-[-1px] h-full flex-shrink px-5 py-3 md:border-l lg:w-[var(--booker-main-width)]" style="opacity: 1; transform: none;">
<div class="[grid-area:main] md:border-subtle -ml-px h-full shrink px-5 py-3 md:border-l lg:w-(--booker-main-width)" style="opacity: 1; transform: none;">
${generateDatePickerSkeleton()}
</div>
</div>
@@ -0,0 +1,8 @@
import { EMBED_DARK_THEME_CLASS, EMBED_LIGHT_THEME_CLASS } from "../constants";
export type ExternalThemeClass = typeof EMBED_DARK_THEME_CLASS | typeof EMBED_LIGHT_THEME_CLASS
export type InternalThemeClass = "dark" | "light"
export function getInternalThemeClass(externalThemeClass: ExternalThemeClass): InternalThemeClass {
return externalThemeClass === EMBED_DARK_THEME_CLASS ? "dark" : "light";
}