-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add SiderSwitch component (#1)
- Loading branch information
1 parent
b43f078
commit ebbd3a2
Showing
6 changed files
with
40 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ dist | |
out | ||
.DS_Store | ||
*.log* | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as SiderSwitch } from './sider-swtich' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react' | ||
import { cn, Switch, SwitchProps } from '@nextui-org/react' | ||
|
||
interface SiderSwitchProps extends SwitchProps { | ||
isShowBorder?: boolean | ||
} | ||
|
||
const SiderSwitch: React.FC<SiderSwitchProps> = (props) => { | ||
const { isShowBorder = false, isSelected, classNames, ...switchProps } = props | ||
|
||
return ( | ||
<Switch | ||
classNames={{ | ||
wrapper: cn('border-2', { | ||
'border-transparent': !isShowBorder | ||
}), | ||
thumb: cn('absolute z-4', { 'transform -translate-x-[2px]': isSelected }), | ||
...classNames | ||
}} | ||
size="sm" | ||
{...switchProps} | ||
/> | ||
) | ||
} | ||
|
||
export default SiderSwitch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters