Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Checkbox and Field with button #123

Merged
merged 12 commits into from
Sep 22, 2023
32 changes: 0 additions & 32 deletions src/atoms/checkbox/__tests__/__snapshots__/checkbox.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,6 @@ exports[`Checkbox renders 1`] = `
cursor: pointer;
}

.c2:checked:not(:disabled)[aria-checked='true'] ~ span {
background-color: #35E0AD;
border-color: #2AB38A;
}

.c2:checked:not(:disabled)[aria-checked='true'] ~ span:after {
display: block;
}

.c2:checked:disabled[aria-checked='true'] ~ span {
border-color: transparent;
background-color: #E3E3E8;
color: #ABACBA;
}

.c2:checked:disabled[aria-checked='true'] ~ span:after {
display: block;
}

.c2:not(:checked):disabled ~ span {
border-color: #E3E3E8;
background-color: #ffffff;
}

.c2:hover:not(:disabled) {
border-color: #4329A6;
}

.c2:hover:not(:disabled):checked ~ span {
border-color: #2AB38A;
}

.c3 {
position: absolute;
top: 0;
Expand Down
4 changes: 2 additions & 2 deletions src/atoms/checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Checkmark,
} from './styles';

interface Props {
export interface CheckboxProps {
value: string;
label?: string | React.ReactNode;
checked?: boolean | undefined;
Expand All @@ -30,7 +30,7 @@ const Checkbox = ({
style,
dataTestId,
required = false,
}: Props) => {
}: CheckboxProps) => {
const checkedRef = useRef<boolean>(checked);
const [isChecked, setIsChecked] = useState(checked);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import { Checkbox } from '../../src';
import Checkbox, { CheckboxProps } from '..';

export default {
title: 'Components/Atoms/Checkbox',
component: Checkbox,
};

export const CheckboxSimpleComponent = args => <Checkbox {...args} />;
export const CheckboxSimpleComponent = (args: CheckboxProps) => (
<Checkbox {...args} />
);

CheckboxSimpleComponent.storyName = 'Simple';
CheckboxSimpleComponent.args = {
Expand All @@ -19,7 +21,7 @@ CheckboxSimpleComponent.args = {
onChange: () => {},
};

export const CheckboxNodeComponent = args => (
export const CheckboxNodeComponent = (args: CheckboxProps) => (
<Checkbox
label={[
'I agree with ',
Expand Down
36 changes: 0 additions & 36 deletions src/atoms/checkbox/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,6 @@ export const CheckboxInput = styled.input<CheckboxWrapperProps>`
left: 0;
opacity: 0;
cursor: pointer;

&:checked:not(:disabled)[aria-checked='true'] ~ span {
background-color: ${props =>
props.error ? field.errorBackgroundColor : field.successBackgroundColor};
border-color: ${props =>
props.error ? field.errorBorderColor : field.successBorderColor};

&:after {
display: block;
}
}

&:checked:disabled[aria-checked='true'] ~ span {
border-color: transparent;
background-color: ${field.disabledBackgroundColor};
color: ${field.disabledColor};

&:after {
display: block;
}
}

&:not(:checked):disabled ~ span {
border-color: ${field.disabledBackgroundColor};
background-color: ${field.backgroundColor};
}

&:hover:not(:disabled) {
border-color: ${props =>
props.error ? field.errorBorderColor : field.activeBorderColor};

&:checked ~ span {
border-color: ${props =>
props.error ? field.errorBorderColor : field.successBorderColor};
}
}
`;

export const Checkmark = styled.span<CheckboxErrorProps>`
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/error-field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { CSSProperties } from 'react';
import * as Styles from './styles';
import { ErrorFieldColor } from './types';

interface ErrorFieldProps {
export interface ErrorFieldProps {
color?: ErrorFieldColor;
error: string;
className?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { ErrorField } from '../../src';
import ErrorField, { ErrorFieldProps } from '..';

export default {
title: 'Components/Atoms/ErrorField',
Expand All @@ -14,15 +14,19 @@ export default {
},
};

export const ErrorComponent = args => <ErrorField {...args} />;
export const ErrorComponent = (args: ErrorFieldProps) => (
<ErrorField {...args} />
);

ErrorComponent.storyName = 'Error';
ErrorComponent.args = {
error: 'Please insert valid name',
color: 'red',
};

export const SuccessComponent = args => <ErrorField {...args} />;
export const SuccessComponent = (args: ErrorFieldProps) => (
<ErrorField {...args} />
);

SuccessComponent.storyName = 'Success';
SuccessComponent.args = {
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/spinner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { CSSProperties } from 'react';
import { colors } from '../../ions/variables';
import * as Styles from './styles';

interface SpinnerProps {
export interface SpinnerProps {
fill?: string;
size?: string;
className?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Spinner } from '../../src';
import Spinner, { SpinnerProps } from '..';

export default {
title: 'Components/Atoms/Spinner',
Expand All @@ -9,7 +9,7 @@ export default {
},
};

export const SpinnerComponent = args => <Spinner {...args} />;
export const SpinnerComponent = (args: SpinnerProps) => <Spinner {...args} />;

SpinnerComponent.storyName = 'Spinner';

Expand Down
2 changes: 1 addition & 1 deletion src/atoms/text-field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ErrorField } from '../..';
import * as Styles from './styles';
import { TextFieldType } from './types';

interface TextFieldProps {
export interface TextFieldProps {
type?: TextFieldType;
error?: string;
icon?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { TextField } from '../../src';
import icons from '../../src/ions/icons';
import TextField, { TextFieldProps } from '..';
import icons from '../../../ions/icons';

export default {
title: 'Components/Atoms/TextField',
Expand All @@ -21,7 +21,7 @@ export default {
},
};

export const TextComponent = args => <TextField {...args} />;
export const TextComponent = (args: TextFieldProps) => <TextField {...args} />;

TextComponent.storyName = 'Text';
TextComponent.args = {
Expand All @@ -34,7 +34,9 @@ TextComponent.args = {
required: false,
};

export const TextDefaultComponent = args => <TextField {...args} />;
export const TextDefaultComponent = (args: TextFieldProps) => (
<TextField {...args} />
);

TextDefaultComponent.storyName = 'Default Value';
TextDefaultComponent.args = {
Expand All @@ -46,7 +48,9 @@ TextDefaultComponent.args = {
disabled: false,
};

export const DisabledComponent = args => <TextField {...args} />;
export const DisabledComponent = (args: TextFieldProps) => (
<TextField {...args} />
);

DisabledComponent.storyName = 'Disabled';
DisabledComponent.args = {
Expand All @@ -58,7 +62,9 @@ DisabledComponent.args = {
disabled: true,
};

export const TextFullBorderComponent = args => <TextField {...args} />;
export const TextFullBorderComponent = (args: TextFieldProps) => (
<TextField {...args} />
);

TextFullBorderComponent.storyName = 'Full Border';
TextFullBorderComponent.args = {
Expand All @@ -69,7 +75,9 @@ TextFullBorderComponent.args = {
disabled: false,
};

export const TextIconComponent = args => <TextField {...args} />;
export const TextIconComponent = (args: TextFieldProps) => (
<TextField {...args} />
);

TextIconComponent.storyName = 'W/ Icon';
TextIconComponent.args = {
Expand All @@ -81,7 +89,7 @@ TextIconComponent.args = {
disabled: false,
};

export const UrlComponent = args => <TextField {...args} />;
export const UrlComponent = (args: TextFieldProps) => <TextField {...args} />;

UrlComponent.storyName = 'URL';
UrlComponent.args = {
Expand All @@ -92,7 +100,9 @@ UrlComponent.args = {
disabled: false,
};

export const PasswordComponent = args => <TextField {...args} />;
export const PasswordComponent = (args: TextFieldProps) => (
<TextField {...args} />
);

PasswordComponent.storyName = 'Password';
PasswordComponent.args = {
Expand All @@ -103,7 +113,7 @@ PasswordComponent.args = {
disabled: false,
};

export const DateComponent = args => <TextField {...args} />;
export const DateComponent = (args: TextFieldProps) => <TextField {...args} />;

DateComponent.storyName = 'Date';
DateComponent.args = {
Expand All @@ -113,7 +123,7 @@ DateComponent.args = {
disabled: false,
};

export const TimeComponent = args => <TextField {...args} />;
export const TimeComponent = (args: TextFieldProps) => <TextField {...args} />;

TimeComponent.storyName = 'Time';
TimeComponent.args = {
Expand All @@ -123,7 +133,9 @@ TimeComponent.args = {
disabled: false,
};

export const NumberComponent = args => <TextField {...args} />;
export const NumberComponent = (args: TextFieldProps) => (
<TextField {...args} />
);

NumberComponent.storyName = 'Number';
NumberComponent.args = {
Expand All @@ -136,7 +148,9 @@ NumberComponent.args = {
disabled: false,
};

export const TextErrorComponent = args => <TextField {...args} />;
export const TextErrorComponent = (args: TextFieldProps) => (
<TextField {...args} />
);

TextErrorComponent.storyName = 'Error';
TextErrorComponent.args = {
Expand Down
4 changes: 2 additions & 2 deletions src/molecules/actions-menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { Button } from '../..';
import { ActionMenu } from './types';
import * as Styles from './styles';

interface ActionsMenuListInterface<T> {
export interface ActionsMenuListInterface<T> {
actions: ActionMenu<T>[];
data?: any;
rowIndex?: number;
handleOptionClick?: () => void;
}

interface ActionsMenuInterface<T> {
export interface ActionsMenuInterface<T> {
className?: string;
ariaLabel?: string;
actions: ActionMenu<T>[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import React from 'react';
import { ActionsMenu } from '../../src';
import ActionsMenu, {
ActionsMenuInterface,
ActionsMenuListInterface,
} from '..';

export default {
title: 'Components/Molecules/ActionsMenu',
component: ActionsMenu,
argTypes: {},
};

export const ActionsMenuOpenComponent = args => <ActionsMenu {...args} />;
type MyActionsMenuListInterface = ActionsMenuListInterface<{
id: string;
type: string;
value: string;
url: string | null;
action: () => void;
}>;

export const ActionsMenuOpenComponent = (
args: ActionsMenuInterface<MyActionsMenuListInterface>
) => <ActionsMenu {...args} />;

const actions = [
{
Expand Down Expand Up @@ -40,7 +53,15 @@ ActionsMenuOpenComponent.args = {
startsOpen: true,
};

export const ActionsMenuClosedComponent = args => <ActionsMenu {...args} />;
export const ActionsMenuClosedComponent = (
args: ActionsMenuInterface<MyActionsMenuListInterface>
) => <ActionsMenu {...args} />;

ActionsMenuClosedComponent.storyName = 'Closed';
ActionsMenuClosedComponent.args = {
...ActionsMenuOpenComponent.args,
startsOpen: false,
};

ActionsMenuClosedComponent.storyName = 'Closed';
ActionsMenuClosedComponent.args = {
Expand Down
Loading
Loading