Skip to content

Commit 9bb6be4

Browse files
committed
basic formatting revisions based on PR feedback
1 parent 80c2af1 commit 9bb6be4

9 files changed

Lines changed: 34 additions & 57 deletions

File tree

src/atoms/anchors/anchor.stories.tsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,16 @@ export default {
1212
component: Anchor,
1313
};
1414

15-
export const plain = () => (
16-
<Anchor to="/test">{Faker.lorem.words(5)}</Anchor>
17-
);
15+
export const Default = () => <Anchor to="/test">{Faker.lorem.words(5)}</Anchor>;
1816

19-
export const icon = () => (
20-
<Anchor
21-
icon = {Icons.Share}
22-
to = "/test"
23-
>{Faker.lorem.words(5)}</Anchor>
24-
)
17+
export const Icon = () => (
18+
<Anchor icon={Icons.Share} to="/test">
19+
{Faker.lorem.words(5)}
20+
</Anchor>
21+
);
2522

26-
export const external = () => (
27-
<Anchor
28-
external = { true }
29-
target = "_blank"
30-
to = "https://www.humanetech.com/"
31-
>Center For Humane Technology</Anchor>
32-
)
23+
export const External = () => (
24+
<Anchor external={true} target="_blank" to="https://www.humanetech.com/">
25+
Center For Humane Technology
26+
</Anchor>
27+
);

src/atoms/anchors/anchor.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface AnchorProps {
1515
children?: any;
1616
cssClassName?: string;
1717
external?: boolean;
18-
icon?: keyof typeof Icons;
18+
icon?: Icons;
1919
id?: string;
2020
onClick?: (e: React.MouseEvent<HTMLElement>, value?: any) => void;
2121
onKeyDown?: (e: React.KeyboardEvent<HTMLAnchorElement>) => void;
@@ -67,12 +67,10 @@ const Anchor: React.RefForwardingComponent<Link, AnchorProps> = forwardRef(
6767
const content = (
6868
<React.Fragment>
6969
{// if
70-
props.icon && (
71-
<Icon type={props.icon} />
72-
)}
70+
props.icon != null && <Icon type={props.icon} />}
7371
{props.children}
7472
</React.Fragment>
75-
)
73+
);
7674

7775
if (props.external === true) {
7876
return (

src/atoms/forms/text-input.test.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,20 @@ describe("TextInput", () => {
6565

6666
test("when icon prop has value, renders input with icon tag", () => {
6767
// Arrange
68+
const dataTestId = "dataTestId";
6869
const icon = Icons.Checkmark;
6970

7071
// Act
71-
const { container } = render(
72-
<TextInput icon={icon} onChange={() => {}} id={uuid()} />
72+
const { getByTestId } = render(
73+
<TextInput
74+
icon={icon}
75+
id={uuid()}
76+
onChange={() => {}}
77+
testId={dataTestId}
78+
/>
7379
);
7480

75-
const result = container.getElementsByClassName("c-text-input")[0].firstChild.nodeName;
76-
7781
// Assert
78-
expect(result).toBe("I");
82+
expect(getByTestId(dataTestId).firstChild.nodeName).toBe("I");
7983
});
8084
});

src/atoms/forms/text-input.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ const TextInput: React.FC<TextInputProps> = (props: TextInputProps) => {
4747

4848
const maxLength = props.maxLength != null ? props.maxLength : 20;
4949

50-
if (icon) {
50+
if (icon != null) {
5151
classNames.push("-icon");
5252
}
5353

5454
return (
5555
<div className={classNames.join(" ")}>
5656
{// if
57-
icon &&
57+
icon != null && (
5858
<Icon type={icon} size={iconSize ?? IconSizes.Large} />
59-
}
59+
)}
6060
<input
6161
aria-labelledby={ariaLabelledBy}
6262
data-testid={testId}

src/atoms/typography/heading.scss

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
@import "../../assets/scss/6-components/_component-base";
22

3-
/*------------------------------------*\
4-
ANCHORS
5-
\*------------------------------------*/
6-
73
.c-heading {
84
display: flex;
95
align-items: center;
106

117
.c-icon {
12-
margin-right: .25em;
8+
margin-right: 0.25em;
139
width: 1em;
1410
height: 1em;
1511
}

src/atoms/typography/heading.stories.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,8 @@ export const headingKnobs = () => {
1818

1919
return (
2020
<Heading
21-
icon={
22-
select(
23-
"icon",
24-
Icons,
25-
Icons.Plus
26-
) as Icons
27-
}
28-
priority={
29-
select(
30-
"priority",
31-
options,
32-
HeadingPriority.One
33-
) as HeadingPriority
34-
}>
21+
icon={select("icon", Icons, Icons.Plus)}
22+
priority={select("priority", options, HeadingPriority.One)}>
3523
Voluptas Expedita Magnam
3624
</Heading>
3725
);

src/atoms/typography/heading.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,10 @@ const Heading: React.FC<HeadingProps> = (
3939
const content = (
4040
<React.Fragment>
4141
{// if
42-
props.icon && (
43-
<Icon type={props.icon} />
44-
)}
45-
<span>
46-
{props.children}
47-
</span>
42+
props.icon != null && <Icon type={props.icon} />}
43+
<span>{props.children}</span>
4844
</React.Fragment>
49-
)
45+
);
5046

5147
return React.createElement(
5248
`h${props.priority ?? HeadingPriority.Two}`,

src/molecules/checkbox-button/checkbox-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { InputTypes } from "../../atoms/constants/input-types";
22
import React from "react";
33
import { Icon } from "../../atoms/icons/icon";
44
import { Icons } from "../../atoms/constants/icons";
5-
import "../checkbox-input/checkbox-input.scss"; // Todo: Remove dependency on external styles
5+
import "../checkbox-input/checkbox-input.scss";
66
import "./checkbox-button.scss";
77

88
// -----------------------------------------------------------------------------------------

src/molecules/radio-input/radio-input.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@import "../../assets/scss/6-components/_component-base";
2-
@import "../../Atoms/buttons/button.scss"; // Todo: Remove this dependency
2+
@import "../../atoms/buttons/button.scss";
33

44
.c-radio {
55
@include padding(16px);

0 commit comments

Comments
 (0)