[THeader, TSwitch] TSwitch 로직 변경 및, THeader Children 추가

This commit is contained in:
hyunwoo93.cha
2024-03-07 14:52:02 +09:00
parent e6a4dd4443
commit 9be38b3673
3 changed files with 41 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import React from "react";
import React, { useCallback } from "react";
import classNames from "classnames";
@@ -12,13 +12,30 @@ const Container = SpotlightContainerDecorator(
"div"
);
const SpottableComponent = Spottable("button");
export default function THeader({ title, className, onBackButton, onClick }) {
export default function THeader({
title,
className,
onBackButton,
onClick,
children,
}) {
const _onClick = useCallback(
(e) => {
if (onClick) {
onClick(e);
}
},
[onClick]
);
return (
<Container className={classNames(css.tHeader, className)}>
{onBackButton && (
<SpottableComponent className={css.button} onClick={onClick} />
<SpottableComponent className={css.button} onClick={_onClick} />
)}
<div className={css.title}>{title}</div>
{children}
</Container>
);
}

View File

@@ -1,12 +1,26 @@
import React from "react";
import React, { useCallback } from "react";
import classNames from "classnames";
import Switch from "../../../node_modules/@enact/sandstone/Switch/Switch";
import css from "../TSwitch/TSwitch.module.less";
export default function TSwitch({ className, onClick }) {
export default function TSwitch({ disabled, className, onClick }) {
const _onClick = useCallback(
(e) => {
if (disabled) {
e.stopPropagation();
return;
}
if (onClick) {
onClick(e);
}
},
[onClick, disabled]
);
return (
<Switch className={classNames(css.tSwitch, className)} onClick={onClick} />
<Switch className={classNames(css.tSwitch, className)} onClick={_onClick} />
);
}

View File

@@ -4,6 +4,10 @@
margin: 0 0 0 10px !important;
> div {
&:first-child {
display: none;
}
&:nth-child(2) {
width: 112px;
height: 53px;