Skip to content

Commit c9cfa12

Browse files
Issue #84 Standardize Atom & Molecule classification
Reclassifies numerous Atoms as Molecules based on their HTML structure. All Atoms with more than 1 HTML element, with the exception of icons and wrappers for icon positioning, have been moved to the Molecules layer. Additionally, there were a handful of icon-variant components that were merged into their base component with the ability to optionally add an icon prop.
2 parents e4e3010 + 9237537 commit c9cfa12

62 files changed

Lines changed: 355 additions & 1029 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/interfaces/radioinputprops.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
[andculturecode-javascript-react-components](../README.md)[RadioInputProps](radioinputprops.md)
2+
3+
# Interface: RadioInputProps
4+
5+
## Hierarchy
6+
7+
* **RadioInputProps**
8+
9+
## Index
10+
11+
### Properties
12+
13+
* [autofocus](radioinputprops.md#optional-autofocus)
14+
* [checked](radioinputprops.md#checked)
15+
* [cssClassName](radioinputprops.md#optional-cssclassname)
16+
* [id](radioinputprops.md#id)
17+
* [label](radioinputprops.md#label)
18+
* [name](radioinputprops.md#name)
19+
* [onCheck](radioinputprops.md#optional-oncheck)
20+
* [onClick](radioinputprops.md#optional-onclick)
21+
* [ref](radioinputprops.md#optional-ref)
22+
* [value](radioinputprops.md#optional-value)
23+
24+
## Properties
25+
26+
### `Optional` autofocus
27+
28+
**autofocus**? : *undefined | false | true*
29+
30+
*Defined in [src/molecules/radio-input/radio-input.tsx:9](https://github.com/phess101/AndcultureCode.JavaScript.React.Components/blob/5fd6ba2/src/molecules/radio-input/radio-input.tsx#L9)*
31+
32+
___
33+
34+
### checked
35+
36+
**checked**: *boolean*
37+
38+
*Defined in [src/molecules/radio-input/radio-input.tsx:10](https://github.com/phess101/AndcultureCode.JavaScript.React.Components/blob/5fd6ba2/src/molecules/radio-input/radio-input.tsx#L10)*
39+
40+
___
41+
42+
### `Optional` cssClassName
43+
44+
**cssClassName**? : *undefined | string*
45+
46+
*Defined in [src/molecules/radio-input/radio-input.tsx:11](https://github.com/phess101/AndcultureCode.JavaScript.React.Components/blob/5fd6ba2/src/molecules/radio-input/radio-input.tsx#L11)*
47+
48+
___
49+
50+
### id
51+
52+
**id**: *string*
53+
54+
*Defined in [src/molecules/radio-input/radio-input.tsx:12](https://github.com/phess101/AndcultureCode.JavaScript.React.Components/blob/5fd6ba2/src/molecules/radio-input/radio-input.tsx#L12)*
55+
56+
___
57+
58+
### label
59+
60+
**label**: *string*
61+
62+
*Defined in [src/molecules/radio-input/radio-input.tsx:13](https://github.com/phess101/AndcultureCode.JavaScript.React.Components/blob/5fd6ba2/src/molecules/radio-input/radio-input.tsx#L13)*
63+
64+
___
65+
66+
### name
67+
68+
**name**: *string*
69+
70+
*Defined in [src/molecules/radio-input/radio-input.tsx:14](https://github.com/phess101/AndcultureCode.JavaScript.React.Components/blob/5fd6ba2/src/molecules/radio-input/radio-input.tsx#L14)*
71+
72+
___
73+
74+
### `Optional` onCheck
75+
76+
**onCheck**? : *undefined | function*
77+
78+
*Defined in [src/molecules/radio-input/radio-input.tsx:15](https://github.com/phess101/AndcultureCode.JavaScript.React.Components/blob/5fd6ba2/src/molecules/radio-input/radio-input.tsx#L15)*
79+
80+
___
81+
82+
### `Optional` onClick
83+
84+
**onClick**? : *undefined | function*
85+
86+
*Defined in [src/molecules/radio-input/radio-input.tsx:16](https://github.com/phess101/AndcultureCode.JavaScript.React.Components/blob/5fd6ba2/src/molecules/radio-input/radio-input.tsx#L16)*
87+
88+
___
89+
90+
### `Optional` ref
91+
92+
**ref**? : *RefObject‹HTMLInputElement› | null*
93+
94+
*Defined in [src/molecules/radio-input/radio-input.tsx:17](https://github.com/phess101/AndcultureCode.JavaScript.React.Components/blob/5fd6ba2/src/molecules/radio-input/radio-input.tsx#L17)*
95+
96+
___
97+
98+
### `Optional` value
99+
100+
**value**? : *string | string[] | number*
101+
102+
*Defined in [src/molecules/radio-input/radio-input.tsx:18](https://github.com/phess101/AndcultureCode.JavaScript.React.Components/blob/5fd6ba2/src/molecules/radio-input/radio-input.tsx#L18)*

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"@reach/menu-button": "0.11.2",
2525
"@tippyjs/react": "4.0.2",
2626
"@types/react": "16.9.11",
27-
"@types/react-beautiful-dnd": "13.0.0",
2827
"@types/react-dom": "16.9.3",
2928
"@types/react-router-dom": "5.1.5",
3029
"andculturecode-javascript-core": "0.1.5",
@@ -35,7 +34,6 @@
3534
"i18next": "19.4.5",
3635
"immutable": "4.0.0-rc.12",
3736
"react": "16.13.1",
38-
"react-beautiful-dnd": "13.0.0",
3937
"react-dom": "16.13.1",
4038
"react-i18next": "11.6.0",
4139
"react-router-dom": "5.1.2",

src/atoms/anchors/anchor-with-icon.stories.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/atoms/anchors/anchor-with-icon.test.tsx

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/atoms/anchors/anchor-with-icon.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/atoms/anchors/anchor.scss

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
\*------------------------------------*/
66

77
a {
8+
display: flex;
9+
align-items: center;
10+
811
@include font-style(
912
$font-primary,
1013
"small",
@@ -13,27 +16,15 @@ a {
1316
16px
1417
);
1518

16-
&.c-button {
17-
display: inline-block;
18-
text-decoration: none;
19-
20-
&.-icon {
21-
text-align: center;
22-
23-
.c-icon {
24-
margin-top: calc(50% - 6px);
25-
26-
&.-large {
27-
margin-top: calc(50% - 12px);
28-
}
29-
}
30-
}
31-
}
32-
3319
&.-secondary {
3420
color: get-color("links", "secondary");
3521
}
22+
3623
&.-disabled {
3724
cursor: not-allowed;
3825
}
26+
27+
.c-icon {
28+
margin-right: .25em;
29+
}
3930
}

src/atoms/anchors/anchor.stories.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,25 @@ import { Anchor } from "./anchor";
33
import Faker from "faker";
44
import { addDecorator } from "@storybook/react";
55
import StoryRouter from "storybook-react-router";
6+
import { Icons } from "../constants/icons";
67

78
addDecorator(StoryRouter());
89

910
export default {
10-
title: "Atoms | Anchors / Anchor",
11+
title: "Atoms | Anchors",
1112
component: Anchor,
1213
};
1314

14-
export const anchorDefault = () => (
15-
<Anchor to="/test">{Faker.lorem.words(5)}</Anchor>
15+
export const Default = () => <Anchor to="/test">{Faker.lorem.words(5)}</Anchor>;
16+
17+
export const Icon = () => (
18+
<Anchor icon={Icons.Share} to="/test">
19+
{Faker.lorem.words(5)}
20+
</Anchor>
21+
);
22+
23+
export const External = () => (
24+
<Anchor external={true} target="_blank" to="https://www.humanetech.com/">
25+
Center For Humane Technology
26+
</Anchor>
1627
);

src/atoms/anchors/anchor.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { act, render, wait, fireEvent } from "@testing-library/react";
33
import { Anchor } from "./anchor";
44
import faker from "faker";
55
import { MemoryRouter } from "react-router-dom";
6+
import { Icons } from "../constants/icons";
67

78
describe("Anchor", () => {
89
it("when default props, renders link with correct url", async () => {
@@ -105,4 +106,24 @@ describe("Anchor", () => {
105106
).not.toBeNull();
106107
});
107108
});
109+
110+
it("when icon prop is set, renders link with icon tag", async () => {
111+
// Arrange
112+
const expected = `/some/random/path/${faker.random.word()}`;
113+
const icon = Icons.Close;
114+
115+
// Act
116+
const { container } = render(
117+
<MemoryRouter>
118+
<Anchor icon={icon} to={expected}>Link</Anchor>
119+
</MemoryRouter>
120+
);
121+
122+
const result = container.getElementsByTagName("a")[0].firstChild.nodeName;
123+
124+
// Assert
125+
await wait(() => {
126+
expect(result).toBe("I");
127+
});
128+
});
108129
});

0 commit comments

Comments
 (0)