fui-fancyui
Version:
FancyUI Libary
85 lines (79 loc) • 2.91 kB
JavaScript
import a from "styled-components";
import { getBackgroundColor as r } from "../../../design/designFunctions/colorCalculatorForComponent/colorCalculatorForComponent.js";
import t from "../../../design/designFunctions/getThemeOrValueAsCss/getThemeOrValueAsCss.js";
import { sizeSettings as i } from "./sizeSettings.js";
const p = a.div`
position: relative;
display: inline-block;
width: calc(${(e) => t(i[e.$sizeC || "md"].height, "elementSize")} * 1.7);
height: ${(e) => t(i[e.$sizeC || "md"].height, "elementSize")};
background-color: ${({ $checked: e, theme: o, $themeType: n, $layer: s }) => e ? r({ theme: o, $themeType: n, $layer: s }) : o.color.secondary[7]};
border-radius: ${t("complete", "borderRadius")};
transition: all 0.2s ease-in-out;
cursor: ${(e) => e.$disabled ? "not-allowed" : "pointer"};
opacity: ${(e) => e.$disabled ? 0.5 : 1};
border: none;
outline: none;
&::before {
content: '';
position: absolute;
top: 50%;
transform: translateY(-50%);
left: ${({ $checked: e, $sizeC: o }) => {
const n = `calc((${t(i[o || "md"].height, "elementSize")} - ${t(i[o || "md"].thumbSize, "elementSize")}) / 2)`;
return e ? `calc(100% - ${t(i[o || "md"].thumbSize, "elementSize")} - ${n})` : n;
}};
width: ${({ $sizeC: e }) => t(i[e || "md"].thumbSize, "elementSize")};
height: ${({ $sizeC: e }) => t(i[e || "md"].thumbSize, "elementSize")};
background-color: ${({ theme: e }) => r({ theme: e, $themeType: "secondary", $layer: 0 })};
border-radius: 50%;
transition: all 0.2s ease-in-out;
pointer-events: none;
z-index: 2;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
input {
position: absolute;
opacity: 0;
width: 100%;
height: 100%;
margin: 0;
cursor: ${(e) => e.$disabled ? "not-allowed" : "pointer"};
}
&:has(input:focus-visible) {
box-shadow: 0 0 0 3px ${({ theme: e }) => e.color.accent[0]}40;
outline: 2px solid ${({ theme: e }) => e.color.accent[0]};
outline-offset: 2px;
}
${(e) => e.$externalStyle}
`, u = a.div`
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 50%;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
z-index: 1;
transition: all 0.2s ease-in-out;
gap: ${t("xs", "spacing")};
svg {
width: calc(${({ $sizeC: e }) => t(i[e || "md"].thumbSize, "elementSize")} / 1.5);
height: calc(${({ $sizeC: e }) => t(i[e || "md"].thumbSize, "elementSize")} / 1.5);
color: ${({ $checked: e, theme: o }) => e ? r({ theme: o, $themeType: "secondary", $layer: 0 }) : o.color.secondary[7]};
transition: all 0.2s ease-in-out;
}
`, h = a.span`
height: 100%;
display: flex;
justify-content: center;
align-items: center;
transition: opacity 0.1s ease-in-out;
`;
export {
u as IconContainer,
h as IconWrapper,
p as SwitchTrack
};