Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrollable graph support #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ body {
--vandal-modal-background-color: #f3f0ea;

/* Input Calendar */
--vandal-input-months-background-color: #4d4c4c;
--vandal-input-months-background-color: #444;
}

.vandal,
Expand Down
2 changes: 1 addition & 1 deletion source/libs/components/common/icon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const icons = {
</svg>
),
leftNav: ({ ...props }) => (
<svg viewBox="13 -1.7 68 107" {...props}>
<svg viewBox="13 -1.7 68 107" style={{ transform: "rotate(180deg)" }} {...props}>
<title>{props.title}</title>
<polygon points="40.6,70.6 37.9,67.7 56.3,50 37.9,32.3 40.6,29.4 62.1,50" />
</svg>
Expand Down
26 changes: 26 additions & 0 deletions source/libs/components/filter/graph/graph.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@
}

.year__container {
position: relative;
display: flex;
justify-content: flex-end;
max-height: 75px;
}

.scroll__wrapper {
display: flex;
width: 97%;
overflow-x: auto;
scroll-behavior: smooth;
}

.scroll__wrapper::-webkit-scrollbar {
display: none;
}

.year {
display: flex;
flex: 0 0 48px;
Expand Down Expand Up @@ -204,3 +216,17 @@
margin-top: 30px;
background: none;
}

.left__scroll__button {
position: absolute;
left: 0;
width: 25px;
height: 100%;
background: #545454;
border: 0;
cursor: pointer;
}

.left__nav__icon {
fill: #fff;
}
64 changes: 38 additions & 26 deletions source/libs/components/filter/graph/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { memo } from "react";
import React, { memo, useRef } from "react";
import PropTypes from "prop-types";
import cx from "classnames";
import _ from "lodash";
Expand Down Expand Up @@ -90,6 +90,7 @@ const GraphFilter = memo((props) => {

let { sparkline } = props;

const scrollRef = useRef();
const { theme } = useTheme();

if (showSparkError || showCalendarError) {
Expand Down Expand Up @@ -150,32 +151,43 @@ const GraphFilter = memo((props) => {
return (
<div className={styles.root}>
<div className={styles.year__container}>
{_.map(years, (y) => (
<div
role="button"
tabIndex={0}
className={cx({
[styles.year]: true,
[styles.year___selected]: theme !== "dark" && currentYear === y,
[styles.year___selected___dark]:
theme === "dark" && currentYear === y
})}
key={`year-${y}`}
onClick={onYearChange(y)}
>
<span className={styles.year__value}>{y}</span>
<Spark
data={sparkline[y]}
margin={0}
width={48}
height={75}
min={0}
max={maxcount}
<button
type="button"
className={styles.left__scroll__button}
onClick={() => {
scrollRef.current.scrollLeft = 0;
}}
>
<Icon name="leftNav" className={styles.left__nav__icon} />
</button>
<div ref={scrollRef} className={styles.scroll__wrapper}>
{_.map(years, (y) => (
<div
role="button"
tabIndex={0}
className={cx({
[styles.year]: true,
[styles.year___selected]: theme !== "dark" && currentYear === y,
[styles.year___selected___dark]:
theme === "dark" && currentYear === y
})}
key={`year-${y}`}
onClick={onYearChange(y)}
>
<Bars theme={theme} />
</Spark>
</div>
))}
<span className={styles.year__value}>{y}</span>
<Spark
data={sparkline[y]}
margin={0}
width={48}
height={75}
min={0}
max={maxcount}
>
<Bars theme={theme} />
</Spark>
</div>
))}
</div>
</div>
{showCalendarLoader && !isOverCapacity && (
<div className={styles.loader__container}>
Expand Down
1 change: 0 additions & 1 deletion source/libs/components/frame/frame.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@
.backward__nav__icon {
width: 24px;
height: 37px;
transform: rotate(180deg);
fill: var(--vandal-primary-icon-color);
stroke: var(--vandal-primary-icon-color);
stroke-width: 3px;
Expand Down