Skip to content

Commit

Permalink
Added onClick event to Circle component
Browse files Browse the repository at this point in the history
  • Loading branch information
Brianx03 authored and geoperez committed Apr 20, 2023
1 parent aeacf97 commit 5f1b362
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 10 additions & 2 deletions sample/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const Application = () => {
const [value, setValue] = React.useState(false);
const [openMenu, setOpenMenu] = React.useState(false);
const [data, setData] = React.useState(defaultData);
const [circleValue, setCircleValue] = React.useState(1234);

const toggle = () => {
setValue(!value);
Expand All @@ -146,6 +147,8 @@ const Application = () => {
setOpenMenu(!openMenu);
};

const CircleClicked = () => setCircleValue(circleValue + 1);

return (
<ThemeProvider theme={baseTheme}>
<NavBar>
Expand All @@ -162,11 +165,16 @@ const Application = () => {
</NavBar>
<BasicToolbar>
<span>This is a toolbar</span>
<DropdownMenu options={options} value={currentOption} label='Options' onOptionClicked={handleOptionChange} />
<DropdownMenu
options={options}
value={currentOption}
label='Options'
onOptionClicked={handleOptionChange}
/>
</BasicToolbar>
<AppContainer rows={5} columns={3} hasToolbar>
<Card column={1} row={1} direction={Directions.ROW} justify={FlexValues.START} fit>
<Circle value={123456} />
<Circle value={circleValue} onClick={CircleClicked} />
<Title>
<h2>TOTAL</h2>
<h3>Rows</h3>
Expand Down
5 changes: 3 additions & 2 deletions src/Circle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface CircleSettings {
color?: Colors;
value?: string | number;
subValue?: string | number;
onClick?: () => void;
}

const calculateSize = (size: SizeValues) => {
Expand Down Expand Up @@ -107,8 +108,8 @@ const Label = ({ size, value }: any) => {
return <span>{value}</span>;
};

export const Circle = ({ value, subValue, color = Colors.BLUE, size = SizeValues.LARGE }: CircleSettings) => (
<StyledCircle color={color} size={size}>
export const Circle = ({ value, subValue, color = Colors.BLUE, size = SizeValues.LARGE, onClick }: CircleSettings) => (
<StyledCircle color={color} size={size} onClick={onClick}>
<Label size={size} value={value} />
{size === SizeValues.LARGE && subValue && <span>{subValue}</span>}
</StyledCircle>
Expand Down

0 comments on commit 5f1b362

Please sign in to comment.