Custom App Icon Component
This commit is contained in:
parent
b532a39be5
commit
546fdc497f
4 changed files with 65 additions and 17 deletions
|
@ -7,7 +7,6 @@
|
||||||
"@testing-library/react": "^9.3.2",
|
"@testing-library/react": "^9.3.2",
|
||||||
"@testing-library/user-event": "^7.1.2",
|
"@testing-library/user-event": "^7.1.2",
|
||||||
"http-server": "^0.12.3",
|
"http-server": "^0.12.3",
|
||||||
"material-icons-react": "^1.0.4",
|
|
||||||
"react": "^16.13.1",
|
"react": "^16.13.1",
|
||||||
"react-dom": "^16.13.1",
|
"react-dom": "^16.13.1",
|
||||||
"react-scripts": "3.4.1",
|
"react-scripts": "3.4.1",
|
||||||
|
|
|
@ -7,7 +7,14 @@
|
||||||
name="description"
|
name="description"
|
||||||
content="Web site created using create-react-app"
|
content="Web site created using create-react-app"
|
||||||
/>
|
/>
|
||||||
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700,900" rel="stylesheet">
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css?family=Roboto:400,500,700,900"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/icon?family=Material+Icons"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
<title>Dashboard</title>
|
<title>Dashboard</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import MaterialIcon from 'material-icons-react';
|
import Icon from './icon';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import selectedTheme from './themeManager';
|
import selectedTheme from './themeManager';
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ const AppDescription = styled.p`
|
||||||
export const App = ({ name, icon, url, displayURL }) => (
|
export const App = ({ name, icon, url, displayURL }) => (
|
||||||
<AppContainer>
|
<AppContainer>
|
||||||
<IconContainer>
|
<IconContainer>
|
||||||
<MaterialIcon icon={icon} color={selectedTheme.mainColor} />
|
<Icon name={icon} color={selectedTheme.mainColor} />
|
||||||
</IconContainer>
|
</IconContainer>
|
||||||
<DetailsContainer>
|
<DetailsContainer>
|
||||||
<AppLink href={url}>{name}</AppLink>
|
<AppLink href={url}>{name}</AppLink>
|
||||||
|
|
42
src/components/icon.js
Normal file
42
src/components/icon.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const IconContainer = styled.i`
|
||||||
|
font-family: 'Material Icons';
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-size: 24px;
|
||||||
|
display: inline-block;
|
||||||
|
line-height: 1;
|
||||||
|
text-transform: none;
|
||||||
|
letter-spacing: normal;
|
||||||
|
word-wrap: normal;
|
||||||
|
white-space: nowrap;
|
||||||
|
direction: ltr;
|
||||||
|
|
||||||
|
/* Support for all WebKit browsers. */
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
/* Support for Safari and Chrome. */
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
|
||||||
|
/* Support for Firefox. */
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
|
||||||
|
/* Support for IE. */
|
||||||
|
font-feature-settings: 'liga';
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const Icon = ({ name, color, size }) => {
|
||||||
|
let Container = IconContainer;
|
||||||
|
|
||||||
|
if (size) {
|
||||||
|
Container = styled(IconContainer)`
|
||||||
|
text-color: ${color};
|
||||||
|
font-size: ${size};
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Container>{name}</Container>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Icon;
|
Loading…
Reference in a new issue