Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              @import url('https://fonts.googleapis.com/css?family=Work+Sans:300,400,600');

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html{
    font-size: 62.5%;
    font-family: 'Work Sans', sans-serif;
    background: #23294c; //#f0f3f6;
}

.app{
    display: flex;
}

.app__content{
    flex-grow: 1;
}

.app__sidebar{
    display: none;
    background: #222A49;
    color: white;
    width: 250px;
    padding: 20px;
}

.app__sidebar--open{
    display: block;
}

.app__header{
    display: flex;
    justify-content: flex-end;
    padding: 2rem 1rem;
    //background: #fff;
}

.app__date{
    display: block;
    //padding: 2rem 2rem 0 2rem;
    font-size: 1.6rem;
    font-weight: 300;
    color: #fff;
}

.client-wrapper{
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-gap: 20px;
    padding: 2rem 2rem;
    
    >*{
        grid-column: auto / span 12;
        @media (min-width: 600px){
            grid-column: auto / span 6;
        }
        
        @media (min-width: 800px){
            grid-column: auto / span 4;
        }
        
        @media (min-width: 1000px){
            grid-column: auto / span 3;
        }
    }
}

.client{
    padding: 2rem 2rem;
    border-radius: 0.5rem;
    background: #2e345a; //#ffffff;
    background: linear-gradient(to bottom right, #2e345a,#3e2e5a);
    box-shadow: 0px 5px 15px rgba(0,0,0,0.125);
    
    &:hover{
        box-shadow: 0px 8px 15px rgba(0,0,0,0.25);
    }
}

.client__name{
    font-weight: 300;
    font-size: 1.3rem;
    margin-bottom: 0.125rem;
    color: #ffffff; //#ef44b1;
}

.client__total-support{
    display: inline-block;
    font-size: 1.4rem;
    margin-bottom: 2rem;
    color: #827ea0;
}

.progress-bar{
    display: flex;
    position: relative;
    flex-grow: 1;
    border-radius: 0.4rem;
    background: linear-gradient(to right,#fa83cf,#ef44b1,#4631e4);
    height: 0.4rem;
    margin-bottom : 1rem;
}

.progress-bar__mask{
    background: #23294c; //#eeeeee;
    width: 100%;
    height: 100%;
    margin-left: auto;
    border-top-right-radius: 0.4rem;
    border-bottom-right-radius: 0.4rem;
    transition: width 1s ease-in-out;
}

.progress{
    display: flex;
}

.progress__used{
    color: #9b97ba;
    font-weight: 400;
    font-size: 1.1rem;
}

.progress__remaining{
    color: #9b97ba;
    margin-left: auto;
    font-weight: 400;
    font-size: 1.1rem;
}
            
          
!
            
              class ClientTracker extends React.Component {

    constructor(props) {
        super(props);
    }

    timeConvertor(totalMinutes) {
        let hours = (totalMinutes / 60);
        let rhours = Math.floor(hours);
        let minutes = (hours - rhours) * 60;
        let rminutes = Math.round(minutes);
        return rhours.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) + ":" + rminutes.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false});
    }
    
    render() {
        return (
            <section className="client">
                <h1 className="client__name">{this.props.name}</h1>
                <span className="client__total-support">{this.timeConvertor(this.props.timeTotal)}</span>

                <div className="progress-bar">
                    <div className="progress-bar__mask" style={{width: this.props.percentageRemaining + '%'}}></div>
                </div>

                <div className="progress">
                    <div className="progress__used">{this.timeConvertor(this.props.timeUsed)} Used</div>
                    <div className="progress__remaining">{this.timeConvertor(this.props.timeRemaining)} Left</div>
                </div>
            </section>
        );
    }
}

class Sorter extends React.Component {

    constructor(props) {
        super(props);
        this.change = this.change.bind(this);
    }

    change(event){
        this.props.changeState({
          order : event.target.value
        });
    }
    
    render() {
        return (
            <select onChange={this.change} value={this.props.order} className="sorter__list">
                <option value="az">A-Z</option>
                <option value="most-support">Most Support Time</option>
                <option value="least-support">Least Support Time</option>
                <option value="most-used">Most % Used</option>
                <option value="least-used">Least % Used</option>
            </select>
        );
    }
}

class App extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            clients: [],
            order: ''
        }
        this.changeOrder = this.changeOrder.bind(this);
    }

    randomTime(min,max){
        return Math.random() * (max - min) + min;
    }
    
    clientDummyData(i){
        const companies = [
            'Stark Industries',
            'Acme Corp.',
            'Springfield Power',
            'Pawtucket Brewery',
            'Cloud Nine',
            'Wayne Enterprises',
            'Cyberdyne Systems',
            'Mr. Plow',
            'Bob\'s Burgers',
            'Pawnee Parks Dept.',
            'Dunder Mifflin',
            'S.H.I.E.L.D',
            'Hammer Industries',
            'Evil Corp',
            'Gringotts Bank',
            'Axe Capital',
            'Duff Beer',
            'Paddy\'s pub',
            'The Krusty Krab',
            'Wayland Industries',
            'Abstergo Industries',
            'The Bluth Company',
            'Hyperion Corporation'
        ];
        
        return companies[i];
    }
    
    sortBy(arr,key,reverse = false){
        return arr.sort((a, b) => {
            let comparison = 0;
            if (a[key] > b[key]) {
                comparison = 1;
            } else if (a[key] < b[key]) {
                comparison = -1;
            }
            
            if(reverse === true){
                return comparison * -1;
            } else {
                return comparison;
            }
        } );  
    }
    
    sortClients(sortBy,clientArr){
        if(sortBy === 'az'){
            return this.sortBy(clientArr,'name');
        } else if(sortBy === 'most-support'){
            return this.sortBy(clientArr,'timeTotal',true);
        } else if(sortBy === 'least-support'){
            return this.sortBy(clientArr,'timeTotal');
        } else if(sortBy === 'most-used'){
            return this.sortBy(clientArr,'percentageUsed',true);
        } else if(sortBy === 'least-used'){
            return this.sortBy(clientArr,'percentageRemaining',true);
        } else {
            return this.sortBy(clientArr,'name');
        }
    }
    
    createClients(num,order){
        let clients = [];
        for(i = 0; i < num; i++){
            let total = this.randomTime(10,400);
            let used = this.randomTime(10,total);
            clients.push(
                {
                    name: this.clientDummyData(i),
                    timeTotal: total,
                    timeUsed: used,
                    timeRemaining: total - used,
                    percentageUsed: 100 - ((total - used) / total * 100),
                    percentageRemaining: (total - used) / total * 100
                }
            );
        }
        console.log(clients);
        return this.sortClients(order,clients);
    }
    
    renderClients(clients){
        let clientComponents = [];
        for(i = 0; i < clients.length; i++){
            clientComponents.push(
                <ClientTracker 
                    name={clients[i].name} 
                    timeTotal={clients[i].timeTotal} 
                    timeUsed={clients[i].timeUsed}
                    timeRemaining={clients[i].timeRemaining}
                    percentageUsed={clients[i].percentageUsed}
                    percentageRemaining={clients[i].percentageRemaining}
                />
            );
        }
        return clientComponents;
    }
    
    changeOrder(orderBy) {
        this.setState(orderBy);
        this.setState({clients: this.sortClients(orderBy.order,this.state.clients)});
    }
    
    toggleSidebar(){
        if(this.state.sidebar === true){
            this.setState({sidebar: false});
        } else {
            this.setState({sidebar: true});
        }
        console.log('toggle Sidebar');
    }

    componentDidMount(){
        this.setState({clients: this.createClients(20,this.state.order)});
    }
    
    render() {
        return (
            <div className="app">
                <section className="app__content">
                    <header className="app__header">
                        <date className="app__date">January 2018</date>
                        <Sorter changeState={this.changeOrder} order={this.state.order} />
                        <button onClick={() => this.toggleSidebar()}>test</button>
                    </header>
                    
                    <div className="client-wrapper">
                        {this.renderClients(this.state.clients,this.state.order)}
                    </div>
                </section>
                <div className={(this.state.sidebar) ? "app__sidebar app__sidebar--open" : "app__sidebar"}>
                    <h1>Sidebar</h1>
                    <p>Features to add:</p> 
                    <p>Detail view button (breakdown of which team members did how much % of the support time).</p>
                    <p>Toggle card/ row layout</p>
                </div>
            </div>
        );
    }
}

ReactDOM.render(
  <App />, 
  document.getElementById('app')
);
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console