Skip to content

Commit 9a67a9b

Browse files
committed
chore: Update package.json version to 1.0.193 and Switch component styles
1 parent 8f0eedb commit 9a67a9b

File tree

3 files changed

+47
-26
lines changed

3 files changed

+47
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@programmer_network/yail",
3-
"version": "1.0.192",
3+
"version": "1.0.193",
44
"description": "Programmer Network's official UI library for React",
55
"author": "Aleksandar Grbic - (https://programmer.network)",
66
"publishConfig": {

src/Components/Inputs/Switch/Switch.stories.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,26 @@ export default {
66
title: "Input / Switch"
77
};
88

9-
export const Default = () => {
10-
const [isChecked, setIsChecked] = useState(false);
9+
export const IsChecked = () => {
10+
return (
11+
<Switch
12+
name='isEnabled'
13+
label='Lorem ipsum'
14+
isChecked={true}
15+
onChange={({ isEnabled }) => console.log(isEnabled)}
16+
/>
17+
);
18+
};
1119

12-
console.log("🚀 ─── Default ─── isChecked:", isChecked);
20+
export const IsNotChecked = () => {
21+
const [isChecked, setIsChecked] = useState(false);
1322

1423
return (
1524
<Switch
25+
name='isEnabled'
26+
label='Lorem ipsum'
1627
isChecked={isChecked}
1728
onChange={({ isEnabled }) => setIsChecked(isEnabled)}
18-
name='isEnabled'
1929
/>
2030
);
2131
};

src/Components/Inputs/Switch/index.tsx

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,44 @@ const Switch: React.FC<ISwitchProps> = ({
77
name,
88
isChecked,
99
onChange,
10-
label = "Toggle me",
10+
label,
1111
className
1212
}) => {
1313
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
1414
onChange({ [name]: event.target.checked });
1515
};
16-
1716
return (
18-
<label
19-
className={classNames(
20-
"yl-inline-flex yl-cursor-pointer yl-items-center",
21-
className
22-
)}
23-
>
24-
<input
25-
type='checkbox'
26-
checked={isChecked}
27-
onChange={handleChange}
28-
className='peer sr-only yl-hidden'
29-
/>
30-
<div className="peer yl-relative yl-h-6 yl-w-12 yl-rounded-full yl-bg-primary-text-color after:yl-absolute after:yl-start-[2px] after:yl-top-[2px] after:yl-h-5 after:yl-w-5 after:yl-rounded-full after:yl-bg-primary-background-color after:yl-transition-all after:yl-content-[''] peer-checked:yl-bg-primary peer-checked:after:yl-translate-x-full rtl:peer-checked:after:-yl-translate-x-full" />
31-
{label && (
32-
<span className='yl-ms-3 yl-text-sm yl-font-medium yl-text-primary-text-color'>
33-
{label}
34-
</span>
35-
)}
36-
</label>
17+
<>
18+
<label className='yl-flex yl-cursor-pointer yl-select-none yl-items-center'>
19+
<div className={classNames("yl-relative", className)}>
20+
<input
21+
type='checkbox'
22+
checked={isChecked}
23+
onChange={handleChange}
24+
className='yl-sr-only'
25+
/>
26+
<div
27+
className={classNames("yl-block yl-h-8 yl-w-14 yl-rounded-full", {
28+
"yl-bg-primary": isChecked,
29+
"yl-bg-primary-text-color": !isChecked
30+
})}
31+
></div>
32+
<div
33+
className={classNames(
34+
"yl-dot yl-absolute yl-left-1 yl-top-1 yl-h-6 yl-w-6 yl-rounded-full yl-transition yl-bg-primary-background-color",
35+
{
36+
"yl-translate-x-6": isChecked
37+
}
38+
)}
39+
></div>
40+
</div>
41+
{label && (
42+
<span className='yl-ms-3 yl-text-sm yl-font-medium yl-text-primary-text-color'>
43+
{label}
44+
</span>
45+
)}
46+
</label>
47+
</>
3748
);
3849
};
3950

0 commit comments

Comments
 (0)