Skip to content

Commit d7d5c4c

Browse files
feat: mobile -> select option for concepts
1 parent eb5a715 commit d7d5c4c

File tree

6 files changed

+81
-34
lines changed

6 files changed

+81
-34
lines changed

src/components/ConceptOptionList/ConceptOptionListItem/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import React from 'react';
1919
import styles from './style.module.css';
2020

2121
const ConceptOptionListItem = ({ value, caption, checked, selectOption }) => (
22-
<div className={styles['flex']}>
22+
<div className={styles['flex-container']}>
2323
<input
2424
checked={checked}
2525
onChange={selectOption}

src/components/ConceptOptionList/ConceptOptionListItem/style.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
.flex {
17+
.flex-container {
1818
display: flex;
1919
align-items: center;
2020
margin: 16px 0;

src/components/ConceptOptionList/index.js

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,39 @@ import React from 'react';
1818

1919
import ConceptOptionListItem from './ConceptOptionListItem';
2020
import { reactLoadingPatterns } from 'utils/data/concepts';
21+
import styles from './style.module.css';
2122

22-
const ConceptOptionList = ({ selectedOptionId, selectOption, className }) => (
23-
<div className={className}>
24-
{reactLoadingPatterns.map(reactLoadingPattern => {
25-
const checked = reactLoadingPattern.id === selectedOptionId;
26-
return (
27-
<ConceptOptionListItem
28-
checked={checked}
29-
selectOption={selectOption}
30-
key={reactLoadingPattern.id}
31-
value={reactLoadingPattern.id}
32-
caption={reactLoadingPattern.optionName} />
33-
);
34-
})}
23+
const ConceptOptionList = ({ selectedOptionId, selectOption }) => (
24+
<div className={styles['flex-container']}>
25+
<h3 className={styles['title']}>
26+
<strong>Category</strong>
27+
</h3>
28+
<select
29+
className={styles['mobile']}
30+
onChange={selectOption}>
31+
{reactLoadingPatterns.map(reactLoadingPattern => {
32+
return (
33+
<option
34+
key={reactLoadingPattern.id}
35+
value={reactLoadingPattern.id}>
36+
{reactLoadingPattern.optionName}
37+
</option>
38+
);
39+
})}
40+
</select>
41+
<div className={styles['desktop']}>
42+
{reactLoadingPatterns.map(reactLoadingPattern => {
43+
const checked = reactLoadingPattern.id === selectedOptionId;
44+
return (
45+
<ConceptOptionListItem
46+
checked={checked}
47+
selectOption={selectOption}
48+
key={reactLoadingPattern.id}
49+
value={reactLoadingPattern.id}
50+
caption={reactLoadingPattern.optionName} />
51+
);
52+
})}
53+
</div>
3554
</div>
3655
);
3756

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the 'License');
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an 'AS IS' BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
.flex-container {
18+
display: flex;
19+
align-items: center;
20+
}
21+
22+
.title {
23+
margin: 12px 8px;
24+
}
25+
26+
.desktop {
27+
display: none;
28+
}
29+
30+
@media screen and (min-width: 1200px) {
31+
.flex-container {
32+
flex-direction: column;
33+
align-items: flex-start;
34+
}
35+
36+
.mobile {
37+
display: none;
38+
}
39+
40+
.desktop {
41+
display: block;
42+
}
43+
}

src/containers/ReactLoadingPatterns/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ const ReactLoadingPatterns = () => {
4545
return (
4646
<div className={styles['root']}>
4747
<h2>React Loading Patterns</h2>
48-
<div className={styles['flex']}>
48+
<div className={styles['flex-container']}>
4949
<ConceptOptionList
50-
className={styles['concept-option-list']}
5150
selectOption={selectPatternHandler}
5251
selectedOptionId={selectedPatternId} />
5352
<CodeArea
Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
.flex {
2+
.flex-container {
33
display: flex;
44
flex-direction: column;
55
}
@@ -13,28 +13,14 @@
1313
flex-grow: 1;
1414
}
1515

16-
.concept-option-list {
17-
display: flex;
18-
flex-wrap: wrap;
19-
}
20-
21-
.concept-option-list div {
22-
flex: 0 0 240px;
23-
}
24-
2516
@media screen and (min-width: 1200px) {
26-
.flex {
17+
.flex-container {
2718
flex-direction: row-reverse;
2819
}
29-
30-
.concept-option-list {
31-
display: unset;
32-
flex: 0 0 260px;
33-
}
3420
}
3521

3622
@media only screen and (max-width: 600px) {
37-
.root{
23+
.root {
3824
margin: 0 4px;
3925
}
4026
}

0 commit comments

Comments
 (0)