Skip to content

Commit 4b84627

Browse files
committed
fixed responsive for ipad (768px)
1 parent bb97ac4 commit 4b84627

File tree

12 files changed

+84
-35
lines changed

12 files changed

+84
-35
lines changed

src/components/Pagination/styles.scss

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
align-items: center;
77
justify-content: center;
88

9-
@include down($mfe-screen-xs) {
9+
@include down(1024px) {
1010
.per-page {
1111
width: 60px;
1212

@@ -20,17 +20,13 @@
2020
}
2121
}
2222

23-
@include down(375px - 1px) {
24-
.label {
25-
display: none;
26-
}
23+
.label {
24+
display: none;
2725
}
2826
}
2927

3028
.pages {
31-
flex: auto;
3229
margin: 0;
33-
justify-content: flex-end;
3430

3531
.page.previous > button,
3632
.page.next > button {
@@ -44,6 +40,14 @@
4440
}
4541
}
4642
}
43+
44+
@include down($mfe-screen-xs) {
45+
.pages {
46+
flex: auto;
47+
margin: 0;
48+
justify-content: flex-end;
49+
}
50+
}
4751
}
4852

4953
.per-page {

src/components/challenge-listing/ChallengeLoading/styles.module.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import "~styles/mixins";
2+
@import "~styles/variables";
23

34
@keyframes placeholderAnim {
45
0% {
@@ -81,4 +82,19 @@
8182
height: 42px;
8283
width: 40px;
8384
}
85+
86+
@include down($mfe-screen-sm) {
87+
.title {
88+
width: 50%;
89+
max-width: 100px;
90+
}
91+
.info {
92+
width: 100%;
93+
max-width: 200px;
94+
}
95+
}
96+
97+
@include down($mfe-screen-xs) {
98+
margin: 0;
99+
}
84100
}

src/containers/Challenges/Listing/ChallengeItem/Tags/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
.tags {
44
margin-top: -5px;
5+
min-width: 1px;
56

67
> * {
78
margin-top: 5px;

src/containers/Challenges/Listing/ChallengeItem/index.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ const ChallengeItem = ({ challenge, onClickTag, onClickTrack, isLoggedIn }) => {
3232
submissionLink += "?tab=submissions";
3333
}
3434

35+
const challengeName = utils.toBreakableWords(
36+
challenge.name,
37+
w => w.length > 20
38+
? `<span style="word-break: break-all">${w}</span>`
39+
: w,
40+
);
41+
3542
return (
3643
<div styleName="challenge-item">
3744
<div styleName="track">
@@ -46,7 +53,7 @@ const ChallengeItem = ({ challenge, onClickTag, onClickTrack, isLoggedIn }) => {
4653
<div styleName="name-container">
4754
<h6 styleName="name">
4855
<Link to={`${CHALLENGES_URL}/${challenge.id}`}>
49-
{challenge.name}
56+
<span dangerouslySetInnerHTML={{__html: challengeName}} />
5057
</Link>
5158
</h6>
5259
<PhaseEndDate

src/containers/Challenges/Listing/ChallengeItem/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
.nums {
2626
width: 0;
2727
flex: none;
28+
29+
> * {
30+
margin: 0 15px;
31+
}
2832
}
2933
}
3034

src/containers/Challenges/Listing/index.jsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ const Listing = ({
123123
</div>
124124
</div>
125125
</Panel.Header>
126-
{loadingChallenges ? (
127-
_.times(3, () => <ChallengeLoading />)
128-
) : challenges.length ? (
126+
{loadingChallenges && (_.times(3, () => <ChallengeLoading />))}
127+
{!loadingChallenges && (challenges.length ? (
129128
<Panel.Body>
130129
{challenges.map((challenge, index) => (
131130
<div
@@ -152,24 +151,28 @@ const Listing = ({
152151
/>
153152
</div>
154153
))}
155-
<div styleName="pagination">
156-
<Pagination
157-
length={total}
158-
pageSize={perPage}
159-
pageIndex={utils.pagination.pageToPageIndex(page)}
160-
onChange={(event) => {
161-
const filterChange = {
162-
page: utils.pagination.pageIndexToPage(event.pageIndex),
163-
perPage: event.pageSize,
164-
};
165-
updateFilter(filterChange);
166-
}}
167-
/>
168-
</div>
169154
</Panel.Body>
170155
) : (
171156
<ChallengeError />
172-
)}
157+
))}
158+
<Panel.Body>
159+
<div styleName="pagination" style={{
160+
display: challenges.length === 0 || loadingChallenges ? 'none' : ''
161+
}}>
162+
<Pagination
163+
length={total}
164+
pageSize={perPage}
165+
pageIndex={utils.pagination.pageToPageIndex(page)}
166+
onChange={(event) => {
167+
const filterChange = {
168+
page: utils.pagination.pageIndexToPage(event.pageIndex),
169+
perPage: event.pageSize,
170+
};
171+
updateFilter(filterChange);
172+
}}
173+
/>
174+
</div>
175+
</Panel.Body>
173176
</Panel>
174177
);
175178
};

src/containers/Challenges/index.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ const Challenges = ({
9999
<Banner />
100100

101101
<div ref={menuRef}>
102-
<h1
102+
<div
103103
styleName={`title ${isScreenXs && menuExpanded ? 'menu-title' : ''}`}
104104
role="button"
105+
tabIndex={-1}
105106
onClick={() => setMenuExpanded(!menuExpanded)}
106107
>
107108
<span>{isScreenXs && menuExpanded ? 'EARN' : 'CHALLENGES'}</span>
@@ -120,7 +121,7 @@ const Challenges = ({
120121
</button>*/}
121122
</span>
122123
)}
123-
</h1>
124+
</div>
124125

125126
{mobileMenu}
126127
</div>

src/containers/Challenges/styles.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
@include down($mfe-screen-xs) {
88
padding: 10px 0;
99
background-color: $tc-white;
10+
11+
:global(.banner) {
12+
margin: 0 20px;
13+
width: calc(100% - 40px);
14+
}
1015
}
1116
}
1217

src/styles/_utils.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727

2828
.sidebar-footer {
29-
margin: 0 auto;
29+
margin: 0 20px;
3030
margin-bottom: 125px;
3131
}
3232

src/utils/hooks/useCssVariable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const useCssVariable = (name, transformFunc) => {
77
const val = style.getPropertyValue(name);
88

99
return transformFunc ? transformFunc(val) : val;
10-
}, [name]);
10+
}, [name, transformFunc]);
1111

1212
return value;
1313
};

src/utils/hooks/useTargetSize.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import React from "react";
22

33
export const useTargetSize = () => {
44
const [size, setSize] = React.useState();
5-
const resizeObserverRef = React.useRef();
65
const ref = React.useRef();
76

87
React.useLayoutEffect(() => {
98
setSize(ref.current.getBoundingClientRect());
10-
}, [ref.current]);
9+
}, []);
1110

1211
React.useLayoutEffect(() => {
13-
resizeObserverRef.current = new ResizeObserver(entries => {
12+
const targetNode = ref.current;
13+
const resizeObserver = new ResizeObserver(entries => {
1414
for (const entry of entries) {
1515
if (entry.contentBoxSize) {
1616
const contentBoxSize = Array.isArray(entry.contentBoxSize)
@@ -22,10 +22,10 @@ export const useTargetSize = () => {
2222
}
2323
}
2424
})
25-
resizeObserverRef.current.observe(ref.current);
25+
resizeObserver.observe(targetNode);
2626

2727
return () => {
28-
resizeObserverRef.current.unobserve(ref.current)
28+
resizeObserver.unobserve(targetNode)
2929
};
3030
}, []);
3131

src/utils/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,11 @@ export function triggerDownload(fileName, blob) {
179179
link.click();
180180
link.parentNode.removeChild(link);
181181
}
182+
183+
export function toBreakableWords(str, breakFunc) {
184+
return str.split(' ').map(hyphenWords => {
185+
return hyphenWords.split('-').map(word => {
186+
return breakFunc(word);
187+
}).join('-');
188+
}).join(' ');
189+
}

0 commit comments

Comments
 (0)