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

docs: Point users to react-fontawesome for icons #364

Merged
merged 8 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,36 @@ Also make sure to include the following in order to import the compiled CSS from

**[More info about using USWDS CSS & SCSS](./docs/scss.md)**

### Icons

[USWDS recommends using Font Awesome](https://designsystem.digital.gov/components/icons/), and that project [provides a package for use with React](https://github.com/FortAwesome/react-fontawesome).

To add this to your project, install react-font-awesome and at least one style of icon:

```
yarn add @fortawesome/fontawesome-svg-core \
@fortawesome/free-solid-svg-icons \
@fortawesome/react-fontawesome
```

You can then add Font Awesome icons to your projects using the `FontAwesome` component:


```jsx
import ReactDOM from 'react-dom'
import { Button } from '@trussworks/react-uswds'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faSave } from '@fortawesome/free-solid-svg-icons'

const button = <Button type="button">
<FontAwesomeIcon icon={faSave} /> Save Changes
</Button>;

ReactDOM.render(button, document.body);
```

For more information on working with and configuring react-fontawesome, please see [that project's documentation](https://github.com/FortAwesome/react-fontawesome#installation). To find specific icons for your project, [search on the Font Awesome site](https://fontawesome.com/icons).

## Maintainers

- [@suzubara](https://github.com/suzubara)
Expand Down
3 changes: 3 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.30",
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"@fortawesome/react-fontawesome": "^0.1.11",
"@testing-library/jest-dom": "^5.11.1",
"@testing-library/react": "^10.4.7",
"@testing-library/user-event": "^12.0.11",
Expand Down
12 changes: 11 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import HomePage from './pages/Home'
import ExamplePage from './pages/Example'
import ModalsPage from './pages/Modals'
import FormsPage from './pages/Forms'
import IconsPage from './pages/Icons'
import { Routes } from './routes'

import './App.css'

const App = () => {
const [mobileNavOpen, setMobileNavOpen] = useState(false)
const { HOME_PAGE, EXAMPLES_PAGE, MODALS_PAGE, FORMS_PAGE } = Routes
const { HOME_PAGE, EXAMPLES_PAGE, MODALS_PAGE, FORMS_PAGE, ICONS_PAGE } = Routes

const toggleMobileNav = (): void => {
setMobileNavOpen((prevOpen) => !prevOpen)
Expand All @@ -41,6 +42,12 @@ const App = () => {
<NavLink to={EXAMPLES_PAGE} activeClassName="usa-current">
Examples
</NavLink>,
<NavLink to={MODALS_PAGE} activeClassName="usa-current">
Modals
</NavLink>,
<NavLink to={ICONS_PAGE} activeClassName="usa-current">
Icons
</NavLink>,
]

return (
Expand Down Expand Up @@ -77,6 +84,9 @@ const App = () => {
<Route path={MODALS_PAGE}>
<ModalsPage />
</Route>
<Route path={ICONS_PAGE}>
<IconsPage />
</Route>
<Route path={FORMS_PAGE}>
<FormsPage />
</Route>
Expand Down
20 changes: 20 additions & 0 deletions example/src/pages/Icons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

import React from 'react'

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faUpload } from '@fortawesome/free-solid-svg-icons'

const IconsPage = (): React.ReactElement => (
<section>
<h1>Icons</h1>

<p className="usa-intro">
We recommend using icons from <a href="https://github.com/FortAwesome/react-fontawesome">react-fontawesome</a> for projects that need icons.
</p>

<FontAwesomeIcon icon={faUpload} /> Upload Image

</section>
)

export default IconsPage
1 change: 1 addition & 0 deletions example/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const Routes = {
EXAMPLES_PAGE: '/examples',
FORMS_PAGE: '/forms',
MODALS_PAGE: '/modals',
ICONS_PAGE: '/icons',
}

export { Routes }
28 changes: 27 additions & 1 deletion example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,32 @@
resolved "https://registry.yarnpkg.com/@csstools/normalize.css/-/normalize.css-10.1.0.tgz#f0950bba18819512d42f7197e56c518aa491cf18"
integrity sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg==

"@fortawesome/fontawesome-common-types@^0.2.30":
version "0.2.30"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.30.tgz#2f1cc5b46bd76723be41d0013a8450c9ba92b777"
integrity sha512-TsRwpTuKwFNiPhk1UfKgw7zNPeV5RhNp2Uw3pws+9gDAkPGKrtjR1y2lI3SYn7+YzyfuNknflpBA1LRKjt7hMg==

"@fortawesome/fontawesome-svg-core@^1.2.30":
version "1.2.30"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.30.tgz#f56dc6791861fe5d1af04fb8abddb94658c576db"
integrity sha512-E3sAXATKCSVnT17HYmZjjbcmwihrNOCkoU7dVMlasrcwiJAHxSKeZ+4WN5O+ElgO/FaYgJmASl8p9N7/B/RttA==
dependencies:
"@fortawesome/fontawesome-common-types" "^0.2.30"

"@fortawesome/free-solid-svg-icons@^5.14.0":
version "5.14.0"
resolved "https://registry.yarnpkg.com/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.14.0.tgz#970453f5e8c4915ad57856c3a0252ac63f6fec18"
integrity sha512-M933RDM8cecaKMWDSk3FRYdnzWGW7kBBlGNGfvqLVwcwhUPNj9gcw+xZMrqBdRqxnSXdl3zWzTCNNGEtFUq67Q==
dependencies:
"@fortawesome/fontawesome-common-types" "^0.2.30"

"@fortawesome/react-fontawesome@^0.1.11":
version "0.1.11"
resolved "https://registry.yarnpkg.com/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.11.tgz#c1a95a2bdb6a18fa97b355a563832e248bf6ef4a"
integrity sha512-sClfojasRifQKI0OPqTy8Ln8iIhnxR/Pv/hukBhWnBz9kQRmqi6JSH3nghlhAY7SUeIIM7B5/D2G8WjX0iepVg==
dependencies:
prop-types "^15.7.2"

"@hapi/[email protected]":
version "2.1.4"
resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5"
Expand Down Expand Up @@ -1495,7 +1521,7 @@
"@babel/runtime" "^7.10.2"

"@trussworks/react-uswds@file:./..":
version "1.7.0"
version "1.8.0"
dependencies:
classnames "^2.2.6"
dotenv "^8.2.0"
Expand Down