Skip to content

Commit

Permalink
⭐️ Impl: Ex - Add CardToggleButton
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Mar 3, 2023
1 parent 5b59d12 commit 0e93f54
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions example/src/components/Card/CardToggleButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react';

import { CardButton } from './CardButton';

export function CardToggleButton(props: {
title: string;
subtitle?: string;
value: boolean;
indicatorOn?: string;
indicatorOff?: string;
onPress: (value: boolean) => void;
}) {
const prefix = props.value
? props.indicatorOn ?? '☀️'
: props.indicatorOff ?? '🌙';

return (
<CardButton
title={`${prefix} ${props.title}`}
subtitle={props.subtitle}
onPress={() => {
props.onPress(!props.value);
}}
/>
);
}
1 change: 1 addition & 0 deletions example/src/components/Card/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './CardRowSwitch';
export * from './CardRowStepper';
export * from './CardRowTextInput';
export * from './CardRowColorPicker';
export * from './CardToggleButton';

0 comments on commit 0e93f54

Please sign in to comment.