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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions apps/scenario-editor/src/routes/-editor-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,5 @@ export function EditorSecondaryButton({ className, ...props }: ComponentPropsWit
* Not from Micropolis C: editor-only export action styling.
*/
export function EditorPrimaryButton({ className, ...props }: ComponentPropsWithoutRef<'button'>) {
return (
<button className={clsx('classicyButton classicyButtonDefault !m-0', className)} {...props} />
);
return <button className={clsx('classicyButton default !m-0', className)} {...props} />;
}
2 changes: 1 addition & 1 deletion apps/scenario-editor/src/routes/-section-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ export function ScenarioMapFinalWorkbench(options: {
activeBrushFamily === 'zones' && option.key === activeZoneOptionKey
}
activeClassName={CLASSICY_MAP_SIDEBAR_BUTTON_ACTIVE_CLASS}
className={`${CLASSICY_MAP_SIDEBAR_BUTTON_CLASS} flex min-h-[3.4rem] items-center justify-center rounded-lg`}
className={`${CLASSICY_MAP_SIDEBAR_BUTTON_CLASS} flex !min-h-[3.4rem] items-center justify-center rounded-lg`}
key={option.key}
onClick={() => {
closeToolVariantContextMenu();
Expand Down
4 changes: 2 additions & 2 deletions apps/scenario-editor/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function EditorTopBar() {
<ClassicyButton
active={fileMenuOpen}
activeClassName={CLASSICY_MENU_BUTTON_ACTIVE_CLASS}
className={`!m-0 min-w-[6.5rem] px-4 py-1.5 ${fileMenuOpen ? CLASSICY_MENU_BUTTON_ACTIVE_CLASS : ''}`}
className={`!m-0 !min-w-[6.5rem] px-4 py-1.5 ${fileMenuOpen ? CLASSICY_MENU_BUTTON_ACTIVE_CLASS : ''}`}
onClick={() => {
setFileMenuOpen((current) => !current);
}}
Expand All @@ -121,7 +121,7 @@ function EditorTopBar() {
<ClassicyButton
active={selected}
activeClassName={CLASSICY_MENU_BUTTON_ACTIVE_CLASS}
className="!m-0 min-w-[8.25rem] px-3 py-1.5"
className="!m-0 !min-w-[8.25rem] px-3 py-1.5"
key={view}
onClick={() => {
if (selected) {
Expand Down
5 changes: 5 additions & 0 deletions apps/scenario-editor/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export default defineConfig({
tailwindcss(),
react(),
],
optimizeDeps: {
// Classicy loads its fonts, art and sounds via `new URL('assets/…', import.meta.url)`;
// pre-bundling relocates the modules and breaks those URLs.
exclude: ['@classicy/classicy', '@classicy/appearance-platinum'],
},
test: {
environment: 'node',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function RuntimeSidebarSection(props: RuntimeSidebarSectionProps) {
}}
title={`${spec.label} ($${spec.baseCost})`}
type="button"
className={`!m-0 flex h-9 min-h-9 max-h-9 w-9 min-w-9 max-w-9 items-center justify-center border-2 p-0 ${
className={`!m-0 flex !h-9 !min-h-9 max-h-9 w-9 min-w-9 max-w-9 items-center justify-center border-2 p-0 ${
active
? '!border-[var(--color-theme-07)] !bg-[var(--color-theme-03)]'
: '!border-[var(--color-black)] !bg-[var(--color-system-02)]'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function RuntimeTopBarSection(props: RuntimeTopBarSectionProps) {
} = props;
const activeToolSpec = getPlayableToolSpec(ui.activeTool);
const menubarButtonClass =
'!m-0 min-w-[calc(var(--window-control-size)*7)] px-2 py-1 text-center';
'!m-0 !min-w-[calc(var(--window-control-size)*7)] px-2 py-1 text-center';
const menubarPanelClass = 'absolute left-0 top-[calc(100%+3px)] z-[12] grid p-1.5';

return (
Expand Down Expand Up @@ -114,7 +114,7 @@ export function RuntimeTopBarSection(props: RuntimeTopBarSectionProps) {
onClick={() => {
simulationActions.playPauseSimulation();
}}
className="!m-0 min-w-21 font-bold"
className="!m-0 !min-w-21 font-bold"
type="button"
>
{session.isSimulationRunning ? 'Pause' : 'Play'}
Expand Down
5 changes: 5 additions & 0 deletions apps/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export default defineConfig({
tailwindcss(),
react(),
],
optimizeDeps: {
// Classicy loads its fonts, art and sounds via `new URL('assets/…', import.meta.url)`;
// pre-bundling relocates the modules and breaks those URLs.
exclude: ['@classicy/classicy', '@classicy/appearance-platinum'],
},
test: {
environment: 'node',
},
Expand Down
3 changes: 2 additions & 1 deletion packages/classicyui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
},
"types": "./src/index.ts",
"dependencies": {
"@classicy/appearance-platinum": "^3.4.0",
"@classicy/classicy": "^3.4.0",
"@radix-ui/react-tooltip": "^1.2.8",
"classicy": "^0.6.31",
"clsx": "2.1.1"
},
"devDependencies": {
Expand Down
10 changes: 8 additions & 2 deletions packages/classicyui/src/classicy-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export interface ClassicyButtonProps extends Omit<
* Mirrors the clickable command widgets from `ref/micropolis/res/micropolis.tcl`
* and `ref/micropolis/res/whead.tcl`.
* Parity note: this is not a 1:1 port of Tcl widget internals; it composes
* Classicy CSS contract classes into a typed React primitive.
* Classicy CSS contract classes into a typed React primitive, applying the same
* default (`md`) padding and margin variant classes as Classicy 3's own
* `ClassicyButton` (padding is skipped for square buttons, as upstream does).
*/
export function ClassicyButton({
active = false,
Expand All @@ -39,9 +41,13 @@ export function ClassicyButton({
{...buttonProps}
className={clsx(
'classicyButton',
isDefault ? 'classicyButtonDefault' : null,
// Classicy 3 marks the default button with a bare `default` class (the
// ring is drawn by the Platinum appearance package).
isDefault ? 'default' : null,
buttonShape === 'square' ? 'classicyButtonShapeSquare' : null,
buttonSize === 'small' ? 'classicyButtonSmall' : null,
buttonShape === 'square' ? null : 'classicyButtonPaddingMd',
'classicyButtonMarginMd',
active ? activeClassName : null,
className,
)}
Expand Down
5 changes: 4 additions & 1 deletion packages/classicyui/src/classicy-checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ export function ClassicyCheckbox({
<input
{...inputProps}
checked={checked}
className={clsx('ClassicyCheckbox', mixed ? 'ClassicyCheckboxMixed' : null, className)}
// Classicy 3 renamed `ClassicyCheckbox` to `classicyCheckbox`; the `X` variant
// keeps the classic `×` mark (the new default is a check), and the mixed
// state is the bare `mixed` modifier (was `ClassicyCheckboxMixed`).
className={clsx('classicyCheckbox classicyCheckboxX', mixed ? 'mixed' : null, className)}
disabled={disabled}
id={resolvedId}
onChange={onChange}
Expand Down
2 changes: 1 addition & 1 deletion packages/classicyui/src/classicy-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function ClassicyDialogPanel({
<section
{...panelProps}
className={clsx(
modalWindow ? 'classicyWindow classicyWindowActive classicyWindowModal' : null,
modalWindow ? 'classicyWindow classicyWindowModal' : null,
'border-solid [border-width:var(--window-border-size)] border-black bg-[var(--color-system-02)]',
CLASSICY_DIALOG_SHADOW,
className,
Expand Down
4 changes: 3 additions & 1 deletion packages/classicyui/src/classicy-popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { createPortal } from 'react-dom';

import { ClassicyMenuPanel, type ClassicyMenuPanelProps } from './classicy-menu.tsx';
import { useClassicyPortalContainer } from './classicy-portal-container.ts';

export type ClassicyPopoverPlacement =
| 'bottom-start'
Expand Down Expand Up @@ -62,6 +63,7 @@ export function ClassicyPopover({
...panelProps
}: ClassicyPopoverProps) {
const panelRef = useRef<HTMLDivElement | null>(null);
const portalContainer = useClassicyPortalContainer();
const [position, setPosition] = useState<ClassicyPopoverPosition>(
CLASSICY_POPOVER_DEFAULT_POSITION,
);
Expand Down Expand Up @@ -171,7 +173,7 @@ export function ClassicyPopover({
>
{children}
</div>,
document.body,
portalContainer ?? document.body,
);
}

Expand Down
17 changes: 17 additions & 0 deletions packages/classicyui/src/classicy-portal-container.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { createContext, useContext } from 'react';

/**
* Holds the Platinum appearance scope element rendered by `ClassicyRuntimeProvider`.
* Not from Micropolis C: browser portal plumbing for the React runtime chrome.
*/
export const ClassicyPortalContainerContext = createContext<HTMLElement | null>(null);

/**
* Returns the element portaled runtime overlays (tooltips, popovers) should mount
* into so they stay inside the Platinum appearance scope, or `null` before the
* scope element mounts (callers fall back to `document.body`).
* Not from Micropolis C: browser portal plumbing for the React runtime chrome.
*/
export function useClassicyPortalContainer(): HTMLElement | null {
return useContext(ClassicyPortalContainerContext);
}
68 changes: 52 additions & 16 deletions packages/classicyui/src/classicy-runtime.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,78 @@
import { ClassicyAppManagerProvider } from 'classicy';
import type { ComponentProps } from 'react';
// Importing the Platinum package registers it with the Classicy core and injects
// its stylesheet and fonts. The core injects its own base stylesheet on import.
import { PLATINUM_APPEARANCE_PACKAGE_ID } from '@classicy/appearance-platinum';
import { ClassicyAppManagerProvider } from '@classicy/classicy';
import { type ComponentProps, useState } from 'react';

import classicyCssText from '../node_modules/classicy/dist/classicy.css?raw';

const CLASSICY_STYLE_ELEMENT_ID = 'classicy-runtime-style-sheet';
import { ClassicyPortalContainerContext } from './classicy-portal-container.ts';

export interface ClassicyRuntimeProviderProps extends ComponentProps<
typeof ClassicyAppManagerProvider
> {}

const CLASSICY_LAYER_ORDER_STYLE_ELEMENT_ID = 'classicy-runtime-layer-order';

/**
* Ensures the Classicy stylesheet is present once for runtime chrome rendering.
* Mirrors global widget style loading used by the Micropolis Tcl UI bootstrap in
* `ref/micropolis/res/micropolis.tcl`.
* Parity note: this injects CSS text into the browser document instead of sourcing Tcl files.
* Pins the cascade layer order so Classicy outranks every Tailwind layer.
* Not from Micropolis C: browser CSS plumbing for the React runtime chrome.
*
* Classicy 3 wraps its CSS in `@layer classicy.*` and prepends its `<style>`
* tags to `<head>`, so its layers are declared first and rank lowest, letting
* Tailwind's preflight (`button { border: 0; background: transparent }`) erase
* the Platinum bevels and disabled faces. Layer order is fixed by the first
* declaration in the document, so this statement is prepended after the
* Classicy imports above have injected their styles.
*
* Classicy goes last (not just above `base`) to keep the precedence the runtime
* chrome was written against: Classicy 0.x CSS was unlayered, so it beat all
* non-important utilities, and call sites use `!`-important utilities (`!m-0`,
* `!min-w-5`, ...) to override it. Important utilities still win here, because
* for `!important` declarations earlier layers take precedence.
*/
function ensureClassicyRuntimeStyles(): void {
function ensureClassicyCascadeLayerOrder(): void {
if (typeof document === 'undefined') {
return;
}
if (document.getElementById(CLASSICY_STYLE_ELEMENT_ID) !== null) {
if (document.getElementById(CLASSICY_LAYER_ORDER_STYLE_ELEMENT_ID) !== null) {
return;
}
const styleElement = document.createElement('style');
styleElement.id = CLASSICY_STYLE_ELEMENT_ID;
styleElement.textContent = classicyCssText;
document.head.append(styleElement);
styleElement.id = CLASSICY_LAYER_ORDER_STYLE_ELEMENT_ID;
styleElement.textContent = '@layer theme, base, components, utilities, classicy;';
document.head.prepend(styleElement);
}

ensureClassicyCascadeLayerOrder();

/**
* Root provider for Classicy runtime state and styling.
* Mirrors top-level app manager setup from `ref/micropolis/res/micropolis.tcl`.
* Parity note: provider wiring is React-managed rather than Tcl command dispatch.
*
* Classicy 3 scopes every Appearance Package rule under
* `.classicyDesktop[data-classicy-appearance=<id>]`, which `ClassicyDesktop`
* normally renders. The runtime does not use `ClassicyDesktop`, so this renders
* that scope itself with `display: contents`: descendants match the Platinum
* selectors and inherit its custom properties, while the core's desktop box
* rules (full-size, overflow hidden, wallpaper) have no box to apply to.
*/
export function ClassicyRuntimeProvider({
children,
...providerProps
}: ClassicyRuntimeProviderProps) {
ensureClassicyRuntimeStyles();
return <ClassicyAppManagerProvider {...providerProps}>{children}</ClassicyAppManagerProvider>;
const [scopeElement, setScopeElement] = useState<HTMLDivElement | null>(null);
return (
<ClassicyAppManagerProvider {...providerProps}>
<div
className="classicyDesktop"
data-classicy-appearance={PLATINUM_APPEARANCE_PACKAGE_ID}
ref={setScopeElement}
style={{ display: 'contents' }}
>
<ClassicyPortalContainerContext.Provider value={scopeElement}>
{children}
</ClassicyPortalContainerContext.Provider>
</div>
</ClassicyAppManagerProvider>
);
}
2 changes: 1 addition & 1 deletion packages/classicyui/src/classicy-toggle-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function ClassicyToggleGroup<Value extends string>({
activeClassName={CLASSICY_TOGGLE_GROUP_ACTIVE_CLASS}
aria-checked={active}
className={clsx(
'!m-0 !min-h-0 min-w-0 flex-1 !px-[0.8rem] !py-[0.45rem] [font-family:var(--header-font),serif] [font-size:calc(var(--header-font-size)*0.86)]',
'!m-0 !min-h-0 !min-w-0 flex-1 !px-[0.8rem] !py-[0.45rem] [font-family:var(--header-font),serif] [font-size:calc(var(--header-font-size)*0.86)]',
!isOnlyOption && index > 0 ? '-ml-[var(--window-border-size)]' : null,
!isOnlyOption && index === 0 ? '!rounded-r-none' : null,
!isOnlyOption && index > 0 && index < options.length - 1 ? '!rounded-none' : null,
Expand Down
5 changes: 4 additions & 1 deletion packages/classicyui/src/classicy-tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
type ReactNode,
} from 'react';

import { useClassicyPortalContainer } from './classicy-portal-container.ts';

const CLASSICY_TOOLTIP_PANEL_SHADOW =
'[box-shadow:inset_calc(var(--window-border-size)*-1)_calc(var(--window-border-size)*-1)_0_0_var(--color-system-05),inset_calc(var(--window-border-size)*1)_calc(var(--window-border-size)*1)_0_0_var(--color-system-07),calc(var(--window-border-size)*2)_calc(var(--window-border-size)*2)_0_0_var(--color-black)]';
const CLASSICY_TOOLTIP_PANEL_BOX_SHADOW =
Expand Down Expand Up @@ -87,6 +89,7 @@ export function ClassicyTooltip({
style,
variant = 'native',
}: ClassicyTooltipProps) {
const portalContainer = useClassicyPortalContainer();
const resolvedNativeTitle = nativeTitle ?? (typeof content === 'string' ? content : undefined);

if (variant === 'native') {
Expand All @@ -99,7 +102,7 @@ export function ClassicyTooltip({
<Tooltip.Provider delayDuration={delayDuration}>
<Tooltip.Root>
<Tooltip.Trigger asChild>{children}</Tooltip.Trigger>
<Tooltip.Portal>
<Tooltip.Portal container={portalContainer}>
<Tooltip.Content
align={align}
className={clsx(className)}
Expand Down
6 changes: 3 additions & 3 deletions packages/classicyui/src/classicy-window.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface ClassicyWindowFrameProps extends HTMLAttributes<HTMLElement> {
* Floating runtime window shell with shared title bar and close control.
* Mirrors detached budget/evaluation/graph window chrome in `ref/micropolis/res/whead.tcl`.
* Parity note: this wraps shared frame structure while callers own placement, z-order, and content.
* The `classicyWindowActive` class is intentionally omitted because upstream CSS
* pins `z-index` with `!important`, which breaks caller-managed stacking order.
* Callers manage z-order; Classicy 3 has no "active window" class (inactive
* windows are marked with `*Dimmed` classes instead), so none is applied here.
*/
export function ClassicyWindowFrame({
bodyClassName,
Expand Down Expand Up @@ -75,7 +75,7 @@ export function ClassicyWindowFrame({
<div className="flex items-center gap-1">
{headerRight}
<ClassicyButton
className="!m-0 min-w-5 !px-1.5 [line-height:1.2]"
className="!m-0 !min-w-5 !px-1.5 [line-height:1.2]"
onPointerDown={stopPropagationOnPointerDown}
onClick={onClose}
title={closeButtonTitle}
Expand Down
3 changes: 2 additions & 1 deletion packages/classicyui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export {
type ClassicyPopoverPlacement,
type ClassicyPopoverProps,
} from './classicy-popover.tsx';
export { useClassicyPortalContainer } from './classicy-portal-container.ts';
export { ClassicyRuntimeProvider, type ClassicyRuntimeProviderProps } from './classicy-runtime.tsx';
export { ClassicyStatRow, type ClassicyStatRowProps } from './classicy-stats.tsx';
export {
Expand All @@ -71,4 +72,4 @@ export {
type ClassicyUIGenericTooltipTriggerProps,
} from './classicy-tooltip.tsx';
export { ClassicyWindowFrame, type ClassicyWindowFrameProps } from './classicy-window.tsx';
export { getAllThemes, getThemeVars } from 'classicy';
export { getAllThemes, getThemeVars } from '@classicy/classicy';
4 changes: 0 additions & 4 deletions packages/classicyui/src/vite-env.d.ts

This file was deleted.

Loading