Skip to content

Commit d3790f0

Browse files
authored
Merge pull request #8774 from TylerAPfledderer/refactor/tutorial-tags-chakra
Refactor: Migrate `TutorialTags` to Chakra UI
2 parents e35cc09 + 3468ad5 commit d3790f0

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/components/Pill.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
2-
import { Flex } from "@chakra-ui/react"
2+
import { Flex, FlexProps } from "@chakra-ui/react"
33

4-
export interface IProps {
4+
export interface IProps extends FlexProps {
55
children?: React.ReactNode
66
className?: string
77
isSecondary?: boolean
@@ -12,7 +12,8 @@ const Pill: React.FC<IProps> = ({
1212
children,
1313
className,
1414
isSecondary,
15-
color,
15+
background,
16+
...rest
1617
}) => {
1718
return isSecondary ? (
1819
<Flex
@@ -28,12 +29,13 @@ const Pill: React.FC<IProps> = ({
2829
borderRadius="base"
2930
fontSize="xs"
3031
className={className}
32+
{...rest}
3133
>
3234
{children}
3335
</Flex>
3436
) : (
3537
<Flex
36-
backgroundColor={color ? color : "primary100"}
38+
background={background ?? "primary100"}
3739
display="inline-block"
3840
color="black300"
3941
textTransform="uppercase"
@@ -44,6 +46,7 @@ const Pill: React.FC<IProps> = ({
4446
fontSize="xs"
4547
borderRadius="base"
4648
className={className}
49+
{...rest}
4750
>
4851
{children}
4952
</Flex>

src/components/TutorialTags.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from "react"
2-
import styled from "@emotion/styled"
32

43
import Pill from "./Pill"
54

@@ -27,12 +26,6 @@ const colors = [
2726
"tagPink",
2827
] as const
2928

30-
const TagPill = styled(Pill)`
31-
margin-right: 0.5rem;
32-
margin-bottom: 0.5rem;
33-
background-color: ${(props) => props.theme.colors[props.color!]};
34-
`
35-
3629
export interface IProps {
3730
tags: Array<string>
3831
}
@@ -44,9 +37,9 @@ const TutorialTags: React.FC<IProps> = ({ tags }) => {
4437
const tagColorIdx = hashCode(tag) % colors.length
4538
const tagColor = colors[tagColorIdx]
4639
return (
47-
<TagPill key={idx} color={tagColor}>
40+
<Pill key={idx} me={2} mb={2} background={tagColor}>
4841
{tag}
49-
</TagPill>
42+
</Pill>
5043
)
5144
})}
5245
</>

0 commit comments

Comments
 (0)