Skip to content

Commit

Permalink
feat: replace themeGet for getSemanticValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Martí Malek committed Jan 26, 2024
1 parent d7770fe commit 05d3b54
Show file tree
Hide file tree
Showing 10 changed files with 336 additions and 221 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Headline, SemanticColors } from '@freenow/wave'
import styled from 'styled-components'

export const DetailsHeadline = styled(Headline).attrs({ as: 'h3', size: 'm' })`
color: ${SemanticColors.text.secondary};
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Headline, getSemanticValue } from '@freenow/wave'
import styled from 'styled-components'

export const DetailsHeadline = styled(Headline).attrs({ as: 'h3', size: 'm' })`
color: ${getSemanticValue('foreground-neutral-emphasized')};
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Box, ChevronUp } from '@freenow/wave';
import { useEffect } from 'react';

export const AlignedChevron = () => {
useEffect(
() =>
function cleanUp() {
// when parsing back from AST to source, function declarations after an arrow function
// are wrapped in parenthesis, by expecting the output to not have the parenthesis we
// can test that instead of parsing back we are simply returning the original source
},
[],
)

return (
<Box display="flex" alignItems="center">
<ChevronUp color="red" />
</Box>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Box, ChevronUp } from '@freenow/wave';
import { useEffect } from 'react';

export const AlignedChevron = () => {
useEffect(
() =>
function cleanUp() {
// when parsing back from AST to source, function declarations after an arrow function
// are wrapped in parenthesis, by expecting the output to not have the parenthesis we
// can test that instead of parsing back we are simply returning the original source
},
[],
)

return (
<Box display="flex" alignItems="center">
<ChevronUp color="red" />
</Box>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CloseIcon, themeGet } from '@freenow/wave';

export const CloseIconWrapper = () => (
<CloseIcon data-testid="dismissBanner" color={themeGet('semanticColors.text.primary')} cursor="pointer" size={18} />
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CloseIcon, getSemanticValue } from '@freenow/wave';

export const CloseIconWrapper = () => (
<CloseIcon data-testid="dismissBanner" color={getSemanticValue('foreground-primary')} cursor="pointer" size={18} />
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Text, themeGet } from '@freenow/wave'
import styled from 'styled-components'

export const TextSizeText = styled(Text)`
color: ${themeGet('semanticColors.text.primary')};
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Text, getSemanticValue } from '@freenow/wave'
import styled from 'styled-components'

export const TextSizeText = styled(Text)`
color: ${getSemanticValue('foreground-primary')};
`
7 changes: 5 additions & 2 deletions src/codemods/__tests__/semantic-colors-to-new-theme-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ jest.autoMockOff();
import { defineTest } from 'jscodeshift/dist/testUtils';

const tests = [
'color-in-JSX-multi-import'
// no-usage
'color-in-JSX-multi-import',
'no-colors-usage',
'theme-get-in-JSX',
'theme-get-in-template-literal',
'color-in-single-quasis'
];

describe('semantic-colors-to-new-theme', () => {
Expand Down
Loading

0 comments on commit 05d3b54

Please sign in to comment.