Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Add --checked-color to checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
juliewongbandue committed Sep 12, 2023
1 parent 2656c6a commit 233c204
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
36 changes: 36 additions & 0 deletions src/components/inputs/Checkbox/Checkbox.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Checkbox, Props } from './Checkbox';

import { Layout } from '../../../storybook';

import styled from 'styled-components';

export default {
title: 'components/Checkbox',
component: Checkbox,
Expand Down Expand Up @@ -32,10 +34,44 @@ export default {
},
};

const StyledCheck = styled(Checkbox)`
// input {
// &:checked ~ div[type='checkbox'] {
// border: 1px solid black;
// &::after {
// border-color: black;
// background-color: black;
// }
// }
// }
--checked-color: black;
`;

const Template: Story<Props> = (args) => {
return (
<Layout.StoryVertical>
<Checkbox {...args} />
<Checkbox label="default checked" value="default" checked />
<Checkbox
label="default checked disabled"
value="default"
checked
disabled
/>
<StyledCheck label="black checked" value="black" checked />
<StyledCheck
label="black disabled"
value="black"
checked
disabled
/>
<StyledCheck
label="black disabled indeterminate"
value="black"
checked
indeterminate
disabled
/>
</Layout.StoryVertical>
);
};
Expand Down
7 changes: 5 additions & 2 deletions src/components/inputs/Input/Input.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export const HiddenMark: StyledComponent<
function fauxMarkChecked({ disabled }) {
return css`
&:checked ~ ${Faux} {
border: 1px solid ${rgba(blue(500), disabled ? 0 : 1)};
border-style: solid;
border-width: 1px;
${!disabled &&
`border-color: var(--checked-color, ${blue(500)})`};
&:after {
opacity: ${disabled ? 0.5 : 1};
Expand Down Expand Up @@ -148,7 +151,7 @@ export function FauxType({ type, size }) {
&:after {
width: 100%;
height: 100%;
border: 1px solid ${blue(500)};
border: 1px solid var(--checked-color, ${blue(500)});
background-image: ${checkmark};
}
`;
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/Shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const FauxMark = (type, mirror) =>
&:after {
content: '';
display: block;
background: ${blue(500)};
background: var(--checked-color, ${blue(500)});
opacity: 0;
transition: 200ms ease-in-out;
transform: scale(0);
Expand Down

0 comments on commit 233c204

Please sign in to comment.