Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Icons page #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import SingleFull from '../../views/Single/SingleFull';
import SinglePage from '../../views/Single/SinglePage';
import Doc from '../../views/Doc/Doc';
import Colors from '../../views/Colors/Colors';
import Icons from '../../views/Icons/Icons';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Icons will be a bit confusing with components/Icon/Icon and components/Icon/Icons...


import './App.css';

Expand Down Expand Up @@ -79,6 +80,7 @@ class App extends Component {
<Route path="/organisms/:slug" component={SingleStyleguide} />
<Route path="/doc/:slug" component={Doc} />
<Route path="/colors" component={Colors} />
<Route path="/icons" component={Icons} />
</div>
</div>
</Theme>
Expand Down
1 change: 1 addition & 0 deletions src/components/IconsTable/IconsTable.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import '../../variables.scss';
3 changes: 3 additions & 0 deletions src/components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const Sidebar = (props) => {
<li>
<NavLink to={'/colors'}>Colors</NavLink>
</li>
<li>
<NavLink to={'/icons'}>Icons</NavLink>
</li>
</ul>

<SidebarDocs location={props.location} />
Expand Down
46 changes: 46 additions & 0 deletions src/views/Icons/Icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React, { Component } from 'react';

import './Icons.css';
import {SET_COMPONENT_MARKUP} from '../../actions/atomic';

class Icons extends Component {
constructor() {
super();

this.state = {
icons: window.icons,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add this logic in a proper Redux collection if it usefull somewhere else.

};
}

renderIconsTable() {
const icons = this.state.icons;

return (
<div className="tlbx-grid">
{Object.keys(icons).map((key) => {
const icon = icons[key];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of a variable for so little and only one usage 😉


return (
<div className="tlbx-icon-wrapper" key={key} title={key}>
<svg className="tlbx-icon"><use xlink="http://www.w3.org/1999/xlink" xlinkHref={`#icon-${key}`} /></svg>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use the Icon component to keep this logic in one place

<span>{icon}</span>
</div>
);
})}
</div>
);
}

render() {
return (
<div>
<h2>Icons</h2>
<div>
{this.state.icons ? this.renderIconsTable() : 'No icons to display'}
</div>
</div>
);
}
}

export default Icons;
31 changes: 31 additions & 0 deletions src/views/Icons/Icons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@import '../../variables.scss';

.tlbx-grid {
display: grid;
grid-gap: 1px;
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.tlbx-icon {
width: 30px;
height: 30px;
margin-bottom: 10px;

svg {
width: 30px;
height: 30px;
}
}

.tlbx-icon-wrapper {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 15px 30px;
background-color: $white;

&:hover {
background-color: white;
}
}