Skip to content

Commit

Permalink
Migrate react swipeable view to swiper
Browse files Browse the repository at this point in the history
Related to #113
  • Loading branch information
sebastienbarbier committed Jun 28, 2023
1 parent cb1602e commit 5e5dd0b
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 273 deletions.
40 changes: 40 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"redux": "^4.2.1",
"redux-persist": "6.0.0",
"redux-thunk": "^2.4.2",
"swiper": "^9.4.1",
"uuid": "^9.0.0",
"workbox-webpack-plugin": "^7.0.0",
"workbox-window": "^7.0.0"
Expand Down
16 changes: 0 additions & 16 deletions src/app/components/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,6 @@ export default function Dashboard(props) {
setOpenTrend(!openTrend);
};

// Handle SwipeableViews (enable/disable based on window.innerWidth)
const [disableSwipeableViews, setDisableSwipeableViews] = useState(
() => window.innerWidth > 600
);
useEffect(() => {
function checkWidth() {
setDisableSwipeableViews(window.innerWidth > 600);
}
window.addEventListener("resize", checkWidth);
return () => {
window.removeEventListener("resize", checkWidth);
};
}, []);

return (
<div className="layout dashboard">

Expand Down Expand Up @@ -175,7 +161,6 @@ export default function Dashboard(props) {
<h2>Balance</h2>

<BalanceView
disableSwipeableViews={disableSwipeableViews}
statistics={statistics}
/>

Expand All @@ -194,7 +179,6 @@ export default function Dashboard(props) {
<Trends
trend30={statistics ? statistics.trend30 : null}
trend7={statistics ? statistics.trend7 : null}
disabled={disableSwipeableViews}
isLoading={!statistics}
onOpenTrend={handleToggleTrend}
/>
Expand Down
23 changes: 14 additions & 9 deletions src/app/components/Transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export default function Transactions(props) {
<UserButton type="button" color="white" onModal={props.onModal} />
</div>
</div>

<div className="indicators showModalSize wrapperMobile">
<div className="view">
<span>Balance&nbsp;</span>
Expand Down Expand Up @@ -283,11 +284,15 @@ export default function Transactions(props) {
</span>
</div>
</div>

<div className="indicators hideModalSize">
<Box
<swiper-container
space-between="0"
class="metrics"
slides-per-view="auto"
style={{ padding: "0 40vw 0 24px" }}
>
<div className="view">
<swiper-slide>
<span>Balance&nbsp;</span>
<span>
{!statistics ? (
Expand All @@ -302,8 +307,8 @@ export default function Transactions(props) {
/>
)}
</span>
</div>
<div className="view">
</swiper-slide>
<swiper-slide>
<span>Expenses&nbsp;</span>
<span>
{!statistics ? (
Expand All @@ -315,8 +320,8 @@ export default function Transactions(props) {
/>
)}
</span>
</div>
<div className="view">
</swiper-slide>
<swiper-slide>
<span>Incomes&nbsp;</span>
<span>
{!statistics ? (
Expand All @@ -328,8 +333,8 @@ export default function Transactions(props) {
/>
)}
</span>
</div>
</Box>
</swiper-slide>
</swiper-container>
</div>
<div className="layout_header_tabs wrapperMobile">
<Tabs
Expand Down Expand Up @@ -397,7 +402,7 @@ export default function Transactions(props) {
</h2>
</div>

<div className="metrics">
<div className="transactions_view">
<div className="metric">
<h3 className="title">Balance</h3>
<div className="balance">
Expand Down
17 changes: 6 additions & 11 deletions src/app/components/Transactions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ div.layout, form.layout {
}
}

swiper-slide {
font-size: 12px;
max-width: 180px;
}

.transactions_two_columns {
width: 100%;
height: 100%;
Expand All @@ -43,17 +48,7 @@ div.layout, form.layout {
h2 {
font-size: 30px;
}
.metrics {
display: flex;
justify-content: center;
background: rgba(170, 170, 170, 0.1);
padding-bottom: 10px;
.incomes_expenses {
p {
margin-right: 10px;
}
}
}

}

@media screen and (min-width: $smallScreen) {
Expand Down

0 comments on commit 5e5dd0b

Please sign in to comment.