('*')) {
+ if (Array.from(element.classList).some((token) => token.startsWith(IDENTITY_CLASS_PREFIX))) {
+ nested.push(element);
+ }
+ }
+ return nested;
+}
+
+test('detects a supported identity class nested beneath the docs identity root', () => {
+ renderInDocsThemeRoot(
+
+ Docs themed example
+
+ Nested application root
+
+
,
+ );
+
+ const host = container;
+ if (!host) throw new Error('Expected the docs theme root');
+
+ const nested = nestedIdentityElementsWithin(host);
+ expect(nested).toHaveLength(1);
+ expect(nested[0]?.className).toContain(themeClassName('product'));
+});
+
+test('rendering the theming examples under the docs identity root adds no nested identity', () => {
+ renderInDocsThemeRoot(
+ <>
+
+
+ >,
+ );
+
+ const host = container;
+ if (!host) throw new Error('Expected the docs theme root');
+
+ expect(nestedIdentityElementsWithin(host)).toEqual([]);
+});
diff --git a/apps/docs/src/examples/theming/color-mode-override.tsx b/apps/docs/src/examples/theming/color-mode-override.tsx
index 548789d1..025f4b5e 100644
--- a/apps/docs/src/examples/theming/color-mode-override.tsx
+++ b/apps/docs/src/examples/theming/color-mode-override.tsx
@@ -4,16 +4,8 @@ import { Text } from '@luke-ui/react/text';
import { vars } from '@luke-ui/react/theme';
import { useState } from 'react';
-type ColorMode = 'dark' | 'light';
-
-const OPPOSITE_MODE: Record = {
- dark: 'light',
- light: 'dark',
-};
-
export default () => {
- const [parentMode, setParentMode] = useState('light');
- const nestedMode = OPPOSITE_MODE[parentMode];
+ const [parentMode, setParentMode] = useState<'light' | 'dark'>('light');
return (
{
color: vars.color.text.primary,
}}
>
- This panel follows the parent mode: {parentMode}.
+ This panel follows the parent mode.
{
color: vars.color.text.primary,
}}
>
- This nested scope forces the opposite mode: {nestedMode}.
+ This panel is fixed to dark mode.
);