Skip to content

Commit 6dec63a

Browse files
committed
Improved Loading UI/UX
1 parent 4f0848a commit 6dec63a

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

examples/github-repos-demo/src/components/loading-card/loading-card.jsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import styled from 'styled-components';
22

3+
import UserPlaceholder from './loading-user-bg.jpg';
4+
import RepoPlaceholder from './loading-repo-bg.jpg';
5+
36
const LoadingCard = styled.div`
4-
width: 33.33%;
7+
width: ${props => (props.userPlaceholder ? '100%' : '33.33%')};
58
padding: 20px;
69
710
@media (max-width: 375px){
@@ -14,7 +17,11 @@ const LoadingCard = styled.div`
1417
1518
> .content{
1619
display: flex;
17-
padding: 20px;
20+
background-image: ${props => (props.userPlaceholder ? `url(${UserPlaceholder})` : `url(${RepoPlaceholder})`)};
21+
background-position: ${props => (props.userPlaceholder ? `left center` : `url(${RepoPlaceholder})`)};
22+
background-repeat: no-repeat;
23+
background-size: contains;
24+
min-height: ${props => (props.userPlaceholder ? `200px` : `250px`)};
1825
background-color: #ffffff;
1926
box-shadow: 0 0 20px rgba(0,0,0,0.1);
2027
flex-direction: column;
Loading
Loading

examples/github-repos-demo/src/components/repos-grid/repos-grid.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import { inject, observer } from 'mobx-react';
33

4-
import Language from '../language/language';
54
import UserCard from '../user-card/user-card';
65
import RepoCard from '../repo-card/repo-card';
76
import LoadingCard from '../loading-card/loading-card';
@@ -11,9 +10,10 @@ import './stylesheets/repos-grid.scss';
1110
const ReposGrid = ({ github }) => (
1211
<div id="ReposGrid">
1312
{github.fetchingData
14-
? <LoadingCard>
15-
<div className="content"><Language resource="FETCHING_DATA" /></div>
16-
</LoadingCard>
13+
? <div style={{ width: '100%' }}>
14+
<LoadingCard userPlaceholder><div className="content" /></LoadingCard>
15+
<LoadingCard repoPlaceholder><div className="content" /></LoadingCard>
16+
</div>
1717
: null}
1818
{!github.fetchingData && github.user
1919
? <UserCard user={github.user} />

examples/github-repos-demo/src/components/search-user/search-user.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const SearchUser = ({ github }) => (
1212
onChange={event => {
1313
github.changeUserToSearchFor(event.target.value);
1414
}}
15+
onKeyPress={event => {
16+
if (event.charCode === 13) github.searchForUser();
17+
}}
1518
type="text"
1619
placeholder="Github username to find repositories"
1720
/>

examples/github-repos-demo/src/stores/github.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default class GithubStore {
1515
}
1616

1717
async fetchFromGithub(endpoint) {
18-
const url = `https://api.github.com${endpoint}?client_id=62b5dd81cbcb92f3cdf9&client_secret=1c41dfda0d56eb31b722049aa60d91eafeb6ebcf`;
18+
const url = `https://api.github.com${endpoint}?client_id=my_client_id&client_secret=my_secret_id`;
1919
const response = await fetch(url);
2020
return await response.json();
2121
}

0 commit comments

Comments
 (0)