Skip to content

Commit 585deb7

Browse files
christophidespPanos Christophides
andauthored
remove background logic from mastercard container and reposition pills (#445)
Co-authored-by: Panos Christophides <[email protected]>
1 parent 51faf9e commit 585deb7

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

src/components/pill/alertMastercard.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ const AlertMasterCard = forwardRef(
6363
zIndex: 2,
6464
...pillProps,
6565
...pillRight,
66+
round: "0 12px 12px 0",
6667
}
6768
const pillEndProps = pillEnd && {
6869
background: pillEndBackground,
6970
margin: [0, 0, 0, -3],
7071
padding: [1, 2, 1, 4],
7172
zIndex: 1,
73+
round: "0 12px 12px 0",
7274
...pillProps,
7375
...pillEnd,
7476
}

src/components/pill/index.stories.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,15 @@ const MasterCards = () => (
208208
<MasterCard
209209
pillLeft={{ flavour: "error", text: "3" }}
210210
pillRight={{ flavour: "warning", text: "2" }}
211+
pillEnd={{ flavour: "clear", text: "223" }}
211212
/>
212213
<MasterCard />
213214
</Flex>
214215
<Flex gap={2}>
215216
<MasterCard
216217
pillLeft={{ flavour: "error", text: "3" }}
217218
pillRight={{ flavour: "warning", text: "2" }}
219+
pillEnd={{ flavour: "clear", text: "223" }}
218220
size="large"
219221
/>
220222
<MasterCard size="large" />
@@ -229,13 +231,15 @@ const AlertMasterCards = () => (
229231
onClick={() => console.log("test")}
230232
pillLeft={{ flavour: "error", text: "3" }}
231233
pillRight={{ flavour: "warning", text: "2" }}
234+
pillEnd={{ flavour: "clear", text: "223" }}
232235
/>
233236
<AlertMasterCard />
234237
</Flex>
235238
<Flex gap={2}>
236239
<AlertMasterCard
237240
pillLeft={{ flavour: "error", text: "3" }}
238241
pillRight={{ flavour: "warning", text: "2" }}
242+
pillEnd={{ flavour: "clear", text: "223" }}
239243
size="large"
240244
/>
241245
<AlertMasterCard size="large" />

src/components/pill/mastercard.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getMasterCardBackground } from "./mixins/background"
44
import { MasterCardContainer } from "./styled"
55

66
const minWidths = {
7-
default: "29px",
7+
default: "22px",
88
large: "37px",
99
}
1010

@@ -21,6 +21,7 @@ const MasterCard = forwardRef(
2121
pillEnd,
2222
round,
2323
size,
24+
zIndex,
2425
...rest
2526
},
2627
ref
@@ -37,35 +38,37 @@ const MasterCard = forwardRef(
3738

3839
const pillLeftProps = {
3940
background: getMasterCardBackground(pillLeft.background, pillLeft.flavour || "disabledError"),
40-
padding: [1, 3],
41+
padding: [0, 3],
4142
position: "relative",
4243
width: { min: minWidths[rest.size] || minWidths.default },
4344
...pillProps,
4445
...pillLeft,
46+
round: "12px",
47+
zIndex: 3,
4548
}
4649
const pillRightProps = {
4750
background: pillRightBackground,
48-
margin: [0, 0, 0, -1],
49-
padding: [1, 2],
51+
margin: [0, 0, 0, -1.5],
52+
padding: [0, 2],
53+
width: { min: minWidths[rest.size] || minWidths.default },
5054
...pillProps,
5155
...pillRight,
56+
round: "0 12px 12px 0",
57+
zIndex: 2,
5258
}
5359
const pillEndProps = pillEnd && {
5460
background: pillEndBackground,
55-
margin: [0, 0, 0, -1],
56-
padding: [1, 2],
61+
margin: [0, 0, 0, -1.5],
62+
padding: [0, 2],
63+
width: { min: minWidths[rest.size] || minWidths.default },
5764
...pillProps,
5865
...pillEnd,
66+
round: "0 12px 12px 0",
67+
zIndex: 1,
5968
}
6069

6170
return (
62-
<MasterCardContainer
63-
background={pillEndBackground || pillRightBackground}
64-
data-testid={testId}
65-
onClick={onClick}
66-
ref={ref}
67-
{...commonProps}
68-
>
71+
<MasterCardContainer data-testid={testId} onClick={onClick} ref={ref} {...commonProps}>
6972
{children || (
7073
<>
7174
<MasterCardPill data-testid={`${testId}-left-pill`} {...pillLeftProps} />

src/components/pill/styled.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const PillContainer = styled(Flex).attrs(
3434
width,
3535
height,
3636
position,
37+
zIndex,
3738
}) => ({
3839
padding: getPillPadding(padding, size, tiny),
3940
round,
@@ -48,6 +49,7 @@ export const PillContainer = styled(Flex).attrs(
4849
justifyContent: "center",
4950
alignItems: "center",
5051
position,
52+
zIndex,
5153
})
5254
)`
5355
${getPillBackground};

0 commit comments

Comments
 (0)