-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: icons not displaying in sign in buttons (#30)
- Fix bug unable to import SVG files in consumer app - Remove SVG files for icons - Uninstall babel file loader - Add icons dictionary
- Loading branch information
Showing
10 changed files
with
117 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { ReactText } from "react"; | ||
import styled from "styled-components"; | ||
import { icons } from "./shared/icons"; | ||
|
||
interface MyType { | ||
[key: string]: string; | ||
} | ||
|
||
interface IconProps { | ||
icon: string; | ||
block?: boolean; | ||
color: string; | ||
fillOpacity: string; | ||
viewBox?: string; | ||
} | ||
|
||
interface PathProps { | ||
[index: string]: number | string; | ||
fillOpacity: ReactText; | ||
} | ||
|
||
const Svg = styled.svg<{ block?: boolean }>` | ||
display: ${({ block }): string => (block ? "block" : "inline-block")}; | ||
vertical-align: middle; | ||
shape-rendering: inherit; | ||
transform: translate3d(0, 0, 0); | ||
`; | ||
|
||
const Path = styled.path<PathProps>` | ||
fill-opacity: ${({ fillOpacity }): ReactText => fillOpacity}; | ||
fill: currentColor; | ||
`; | ||
|
||
/** | ||
* An Icon is a piece of visual element, but we must ensure its accessibility while using it. | ||
* It can have 2 purposes: | ||
* | ||
* - *decorative only*: for example, it illustrates a label next to it. | ||
* We must ensure that it is ignored by screen readers, | ||
* by setting `aria-hidden` attribute (ex: `<Icon icon="check" aria-hidden />`) | ||
* - *non-decorative*: it means that it delivers information. | ||
* For example, an icon as only child in a button. | ||
* The meaning can be obvious visually, but it must have a proper text alternative via | ||
* `aria-label` for screen readers (ex: `<Icon icon="print" aria-label="Print this document" />`) | ||
*/ | ||
|
||
export const Icon: React.FC<IconProps> = ({ | ||
icon, | ||
block, | ||
color, | ||
fillOpacity, | ||
viewBox, | ||
}: IconProps) => { | ||
const viewBoxProp = viewBox || "0 0 24 24"; | ||
return ( | ||
<Svg viewBox={viewBoxProp} width="24px" height="24px" block={block}> | ||
<Path color={color} fillOpacity={fillOpacity} d={icons[icon]} /> | ||
</Svg> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
import React from "react"; | ||
import { SignInButton } from "./SignInButton"; | ||
import { FacebookIcon, GoogleIcon, EmailIcon } from "./SignIn.styles"; | ||
|
||
export default { | ||
title: "Sign In Button", | ||
}; | ||
|
||
export const Facebook: React.FC = () => ( | ||
<SignInButton borderColor="#3b5998" icon={<FacebookIcon />}> | ||
<SignInButton type="facebook" bordercolor="#3b5998"> | ||
Continue with Facebook | ||
</SignInButton> | ||
); | ||
|
||
export const Google: React.FC = () => ( | ||
<SignInButton borderColor="#db4437" icon={<GoogleIcon />}> | ||
<SignInButton type="google" bordercolor="#db4437"> | ||
Continue with Google | ||
</SignInButton> | ||
); | ||
|
||
export const Email: React.FC = () => ( | ||
<SignInButton borderColor="#5600e8" icon={<EmailIcon />}> | ||
<SignInButton type="email" bordercolor="#5600e8"> | ||
Continue with Email | ||
</SignInButton> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Icon paths | ||
interface ReadonlyStringArray { | ||
readonly [index: string]: number | string; | ||
} | ||
|
||
export const icons: ReadonlyStringArray = { | ||
facebook: | ||
"M7.59 23.832V13.3h3.403l.51-4.107H7.59V6.571c0-1.189.317-1.999 1.96-1.999h2.092V.897c-.362-.049-1.604-.16-3.05-.16-3.018 0-5.084 1.913-5.084 5.426v3.028H.094V13.3h3.414v10.533z", | ||
google: | ||
"M12.464 10.371H23.59c.123.672.185 1.313.185 1.925 0 2.175-.466 4.117-1.397 5.826-.93 1.71-2.258 3.045-3.982 4.007-1.724.962-3.7 1.443-5.93 1.443-1.607 0-3.136-.303-4.589-.91-1.453-.606-2.706-1.425-3.76-2.458-1.053-1.032-1.89-2.26-2.508-3.683a11.155 11.155 0 0 1-.929-4.496c0-1.574.31-3.072.929-4.496.619-1.423 1.455-2.651 2.509-3.683 1.053-1.033 2.306-1.852 3.76-2.459a11.791 11.791 0 0 1 4.587-.91c3.07 0 5.704 1.008 7.903 3.023L17.16 6.522c-1.258-1.193-2.824-1.79-4.696-1.79-1.32 0-2.54.326-3.66.978a7.274 7.274 0 0 0-2.662 2.654 7.114 7.114 0 0 0-.982 3.661c0 1.323.327 2.544.982 3.661a7.274 7.274 0 0 0 2.662 2.654c1.12.652 2.34.977 3.66.977.89 0 1.709-.12 2.455-.36.747-.241 1.361-.542 1.842-.903.48-.36.9-.771 1.258-1.233.358-.46.622-.897.79-1.308a5.44 5.44 0 0 0 .346-1.172h-6.69z", | ||
email: | ||
"M12.226 15.604c-2.13 0-3.849-1.72-3.849-3.849 0-2.13 1.72-3.85 3.85-3.85s3.848 1.72 3.848 3.85-1.719 3.85-3.849 3.85zm0-15.396C5.852.207.68 5.38.68 11.755c0 6.374 5.173 11.547 11.547 11.547H18v-2.309h-5.774c-5.011 0-9.237-4.226-9.237-9.238s4.226-9.238 9.237-9.238c5.012 0 9.238 4.226 9.238 9.238v1.651c0 .913-.82 1.813-1.732 1.813S18 14.32 18 13.406v-1.651a5.776 5.776 0 0 0-5.774-5.774 5.776 5.776 0 0 0-5.773 5.774 5.776 5.776 0 0 0 5.773 5.774 5.74 5.74 0 0 0 4.088-1.698c.75 1.028 2.044 1.698 3.418 1.698 2.275 0 4.042-1.848 4.042-4.123v-1.651C23.774 5.381 18.6.207 12.226.207z", | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
7d5e3f7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: