Skip to content

Commit

Permalink
fix(core): Fix name + componentName themes not searching upwards
Browse files Browse the repository at this point in the history
  • Loading branch information
natew committed Dec 5, 2022
1 parent 09269e3 commit 3eee04b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/site/components/HeroExampleCode.tsx
Expand Up @@ -151,9 +151,9 @@ const CodeExamples = memo(({ examples }: any) => {
<XStack maxWidth="100%" f={1}>
<YStack f={1} maxWidth="100%" opacity={0.9} hoverStyle={{ opacity: 1 }}>
<CodeDemoPreParsed
height={300}
height={325}
theme="Card"
maxHeight={300}
maxHeight={325}
f={1}
language={example.language}
source={example.code}
Expand Down
17 changes: 17 additions & 0 deletions packages/core/src/helpers/ThemeManager.test.tsx
Expand Up @@ -477,4 +477,21 @@ describe('ThemeManager', () => {
)
expect(child.state.name).toBe('dark_yellow_Button')
})

test(`Component name + name finds one up when component name missing`, () => {
const parent = new ThemeManager(
{
name: 'dark_red_alt1',
},
'root'
)
const child = new ThemeManager(
{
name: 'alt2',
componentName: 'Missing',
},
parent
)
expect(child.state.name).toBe('dark_red_alt2')
})
})
7 changes: 4 additions & 3 deletions packages/core/src/helpers/ThemeManager.tsx
Expand Up @@ -176,9 +176,10 @@ function getState(
? base.slice(0, base.length).join(THEME_NAME_SEPARATOR)
: parentName
const max = base.length
const min = componentName
? max // component themes don't search upwards
: 0
const min =
componentName && !nextName
? max // component name only don't search upwards
: 0

// prettier-ignore
// eslint-disable-next-line no-console
Expand Down

1 comment on commit 3eee04b

@vercel
Copy link

@vercel vercel bot commented on 3eee04b Dec 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

site – ./

site-git-master-tamagui.vercel.app
site-tamagui.vercel.app
site-beta-beige.vercel.app

Please sign in to comment.