Improved tags list section

This commit is contained in:
Alejandro Celaya 2018-08-16 19:19:57 +02:00
parent 49290b56ee
commit f7f0d8c7c1
5 changed files with 79 additions and 28 deletions

View file

@ -29,6 +29,7 @@ export default function AsideMenu({ selectedServer, className, showOnMobile }) {
return (
<aside className={asideClass}>
<nav className="nav flex-column aside-menu__nav">
<h4 className="aside-menu__nav-group-title">Short URLs</h4>
<NavLink
className="aside-menu__item"
activeClassName="aside-menu__item--selected"
@ -45,6 +46,8 @@ export default function AsideMenu({ selectedServer, className, showOnMobile }) {
<FontAwesomeIcon icon={createIcon} flip="horizontal" />
<span className="aside-menu__item-text">Create short URL</span>
</NavLink>
<h4 className="aside-menu__nav-group-title">Tags</h4>
<NavLink
className="aside-menu__item"
activeClassName="aside-menu__item--selected"

View file

@ -1,5 +1,6 @@
@import '../utils/base';
@import '../utils/mixins/box-shadow';
@import '../utils/mixins/vertical-align';
$asideMenuMobileWidth: 280px;
@ -74,3 +75,22 @@ $asideMenuMobileWidth: 280px;
.aside-menu__item-text {
margin-left: 8px;
}
.aside-menu__nav-group-title {
font-size: .9rem;
text-align: center;
color: #bbb;
text-shadow: 1px 1px #ddd;
position: relative;
&:before {
@include vertical-align();
left: 0;
width: 100%;
height: 1px;
background: red;
}
}
.aside-menu__nav-group-title:not(:first-child) {
margin-top: 1rem;
}

View file

@ -10,15 +10,7 @@ import DateInput from '../common/DateInput'
import VisitsParser from '../visits/services/VisitsParser'
import { getShortUrlVisits } from './reducers/shortUrlVisits'
import './ShortUrlVisits.scss'
const MutedMessage = ({ children }) =>
<div className="col-md-10 offset-md-1">
<Card className="bg-light mt-4" body>
<h3 className="text-center text-muted mb-0">
{children}
</h3>
</Card>
</div>;
import MutedMessage from '../utils/MuttedMessage';
export class ShortUrlsVisits extends React.Component {
state = { startDate: undefined, endDate: undefined };

View file

@ -5,6 +5,9 @@ import { listTags } from './reducers/tagsList';
import './TagsList.scss';
import { Card } from 'reactstrap';
import ColorGenerator from '../utils/ColorGenerator';
import MuttedMessage from '../utils/MuttedMessage';
const { round } = Math;
export class TagsList extends React.Component {
componentDidMount() {
@ -12,24 +15,31 @@ export class TagsList extends React.Component {
listTags();
}
render() {
renderContent() {
const { tagsList, colorGenerator } = this.props;
const tagsCount = Math.round(tagsList.tags.length);
if (tagsCount < 1) {
return <div>No tags</div>;
if (tagsList.loading) {
return <MuttedMessage>Loading...</MuttedMessage>
}
const tagsGroups = splitEvery(Math.round(tagsCount / 4), tagsList.tags);
if (tagsList.error) {
return <div className="bg-danger p-2 text-white text-center">Error loading tags :(</div>;
}
const tagsCount = tagsList.tags.length;
if (tagsCount < 1) {
return <MuttedMessage>No tags found</MuttedMessage>;
}
const tagsGroups = splitEvery(round(tagsCount / 4), tagsList.tags);
return (
<div className="shlink-container">
<div className="row">
<React.Fragment>
{tagsGroups.map((group, index) => (
<div key={index} className="col-md-6 col-xl-3">
{group.map(tag => (
<div
style={{ backgroundColor: colorGenerator.getColorForKey(tag) }}
className="tags-list__tag-container"
key={tag}
>
<Card body className="tags-list__tag-card">
<h5 className="tags-list__tag-title">{tag}</h5>
@ -38,6 +48,15 @@ export class TagsList extends React.Component {
))}
</div>
))}
</React.Fragment>
);
}
render() {
return (
<div className="shlink-container">
<div className="row">
{this.renderContent()}
</div>
</div>
);

View file

@ -0,0 +1,17 @@
import React from 'react';
import { Card } from 'reactstrap';
import classnames from 'classnames';
export default function MutedMessage({ children, marginSize = 4 }) {
const cardClasses = classnames('bg-light', `mt-${marginSize}`);
return (
<div className="col-md-10 offset-md-1">
<Card className={cardClasses} body>
<h3 className="text-center text-muted mb-0">
{children}
</h3>
</Card>
</div>
);
}