fix conflict
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
commit
3be5395353
|
@ -0,0 +1,69 @@
|
|||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: node16
|
||||
|
||||
steps:
|
||||
- name: view-staging-url
|
||||
image: node:16
|
||||
commands:
|
||||
- echo "staging url will be https://${DRONE_BRANCH//\//-}-csc-class-profile-staging-snedadah.k8s.csclub.cloud"
|
||||
|
||||
- name: install-deps
|
||||
image: node:16
|
||||
commands:
|
||||
- npm install
|
||||
|
||||
- name: lint
|
||||
image: node:16
|
||||
depends_on:
|
||||
- install-deps
|
||||
commands:
|
||||
- npm run lint
|
||||
|
||||
- name: build
|
||||
image: node:16
|
||||
depends_on:
|
||||
- install-deps
|
||||
commands:
|
||||
- npm run build
|
||||
|
||||
- name: export
|
||||
image: node:16
|
||||
depends_on:
|
||||
- build
|
||||
commands:
|
||||
- npm run export
|
||||
|
||||
- name: publish
|
||||
image: plugins/docker:latest
|
||||
depends_on:
|
||||
- export
|
||||
settings:
|
||||
username:
|
||||
from_secret: HARBOUR_USERNAME
|
||||
password:
|
||||
from_secret: HARBOUR_PASSWORD
|
||||
tags:
|
||||
- ${DRONE_BRANCH//\//-}
|
||||
- latest
|
||||
registry: registry.cloud.csclub.uwaterloo.ca
|
||||
repo: registry.cloud.csclub.uwaterloo.ca/snedadah/csc-class-profile-staging
|
||||
|
||||
- name: deploy
|
||||
image: node:16
|
||||
depends_on:
|
||||
- publish
|
||||
environment:
|
||||
STAGING_AUTH_TOKEN:
|
||||
from_secret: STAGING_AUTH_TOKEN
|
||||
commands:
|
||||
- echo "The docker build tag is ${DRONE_BRANCH//\//-}"
|
||||
- 'curl -H "Authorization: $STAGING_AUTH_TOKEN" https://csclub.uwaterloo.ca/~snedadah/webhooks/cscclassprofilestaging?ref=${DRONE_BRANCH//\//-}'
|
||||
|
||||
trigger:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request #avoid double build on PRs
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
FROM nginx
|
||||
COPY ./out /usr/share/nginx/html
|
||||
|
||||
COPY staging-nginx.conf /etc/nginx/conf.d
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
|
@ -0,0 +1,36 @@
|
|||
.barBackground {
|
||||
fill: var(--card-background);
|
||||
}
|
||||
|
||||
.bar {
|
||||
fill: var(--primary-accent-light);
|
||||
}
|
||||
|
||||
.barText {
|
||||
visibility: hidden;
|
||||
|
||||
font-family: "Inconsolata", monospace;
|
||||
font-weight: 800;
|
||||
fill: var(--label);
|
||||
}
|
||||
|
||||
.barGroup:hover .bar {
|
||||
fill: var(--primary-accent);
|
||||
filter: drop-shadow(0 0 calc(4rem / 16) var(--primary-accent));
|
||||
}
|
||||
|
||||
.barGroup:hover .barText {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.tickLabel {
|
||||
font-family: "Inconsolata", monospace;
|
||||
font-weight: 800;
|
||||
fill: var(--label);
|
||||
}
|
||||
|
||||
.axisLabel {
|
||||
font-family: "Inconsolata", monospace;
|
||||
font-weight: 800;
|
||||
fill: var(--label);
|
||||
}
|
|
@ -0,0 +1,353 @@
|
|||
import { AxisBottom, AxisLeft } from "@visx/axis";
|
||||
import { bottomTickLabelProps } from "@visx/axis/lib/axis/AxisBottom";
|
||||
import { leftTickLabelProps } from "@visx/axis/lib/axis/AxisLeft";
|
||||
import { GridColumns, GridRows } from "@visx/grid";
|
||||
import { Group } from "@visx/group";
|
||||
import { scaleBand, scaleLinear } from "@visx/scale";
|
||||
import { Bar } from "@visx/shape";
|
||||
import { Text } from "@visx/text";
|
||||
import React from "react";
|
||||
import { Color } from "utils/Color";
|
||||
|
||||
import styles from "./BarGraph.module.css";
|
||||
|
||||
interface BarGraphProps {
|
||||
data: BarGraphData[];
|
||||
/** Width of the entire graph, in pixels. */
|
||||
width: number;
|
||||
/** Height of the entire graph, in pixels. */
|
||||
height: number;
|
||||
/** Distance between the edge of the graph and the area where the bars are drawn, in pixels. */
|
||||
margin: {
|
||||
top: number;
|
||||
bottom: number;
|
||||
left: number;
|
||||
right: number;
|
||||
};
|
||||
className?: string;
|
||||
/** Font size of the category tick labels, in pixels. Default is 16px. */
|
||||
categoryTickLabelSize?: number;
|
||||
/** Font size of the value tick labels, in pixels. Default is 16px. */
|
||||
valueTickLabelSize?: number;
|
||||
/** Font size of the value that appears when hovering over a bar, in pixels. */
|
||||
hoverLabelSize?: number;
|
||||
/** Label text for the category axis. */
|
||||
categoryAxisLabel?: string;
|
||||
/** Font size of the label for the cateogry axis, in pixels. */
|
||||
categoryAxisLabelSize?: number;
|
||||
/** Controls the distance between the category axis label and the category axis. */
|
||||
categoryAxisLabelOffset?: number;
|
||||
/** Label text for the value axis. */
|
||||
valueAxisLabel?: string;
|
||||
/** Font size of the label for the value axis, in pixels. */
|
||||
valueAxisLabelSize?: number;
|
||||
/** Controls the distance between the value axis label and the value axis. */
|
||||
valueAxisLabelOffset?: number;
|
||||
}
|
||||
|
||||
interface BarGraphData {
|
||||
category: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
const DEFAULT_LABEL_SIZE = 16;
|
||||
|
||||
export function BarGraphHorizontal(props: BarGraphProps) {
|
||||
const {
|
||||
width,
|
||||
height,
|
||||
margin,
|
||||
data,
|
||||
className,
|
||||
categoryTickLabelSize = DEFAULT_LABEL_SIZE,
|
||||
valueTickLabelSize = DEFAULT_LABEL_SIZE,
|
||||
hoverLabelSize,
|
||||
categoryAxisLabel,
|
||||
categoryAxisLabelSize = DEFAULT_LABEL_SIZE,
|
||||
categoryAxisLabelOffset = 0,
|
||||
valueAxisLabel,
|
||||
valueAxisLabelSize = DEFAULT_LABEL_SIZE,
|
||||
valueAxisLabelOffset = 0,
|
||||
} = props;
|
||||
|
||||
const barPadding = 0.4;
|
||||
|
||||
const categoryMax = height - margin.top - margin.bottom;
|
||||
const valueMax = width - margin.left - margin.right;
|
||||
|
||||
const getCategory = (d: BarGraphData) => d.category;
|
||||
const getValue = (d: BarGraphData) => d.value;
|
||||
|
||||
const categoryScale = scaleBand({
|
||||
range: [0, categoryMax],
|
||||
domain: data.map(getCategory),
|
||||
padding: barPadding,
|
||||
});
|
||||
|
||||
const valueScale = scaleLinear({
|
||||
range: [0, valueMax],
|
||||
nice: true,
|
||||
domain: [0, Math.max(...data.map(getValue))],
|
||||
});
|
||||
|
||||
const categoryPoint = (d: BarGraphData) => categoryScale(getCategory(d));
|
||||
const valuePoint = (d: BarGraphData) => valueScale(getValue(d));
|
||||
|
||||
return (
|
||||
<svg className={className} width={width} height={height}>
|
||||
<Group top={margin.top} left={margin.left}>
|
||||
<Group>
|
||||
{data.map((d, idx) => {
|
||||
const barName = `${getCategory(d)}-${idx}`;
|
||||
const barWidth = categoryScale.bandwidth();
|
||||
const backgroundBarWidth = barWidth / (1 - barPadding);
|
||||
return idx % 2 === 0 ? (
|
||||
<Bar
|
||||
className={styles.barBackground}
|
||||
key={`bar-${barName}-background`}
|
||||
x={0}
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
y={categoryPoint(d)! - (backgroundBarWidth - barWidth) / 2}
|
||||
width={valueMax}
|
||||
height={backgroundBarWidth}
|
||||
/>
|
||||
) : null;
|
||||
})}
|
||||
</Group>
|
||||
<GridColumns
|
||||
scale={valueScale}
|
||||
height={categoryMax}
|
||||
numTicks={5}
|
||||
stroke={Color.label}
|
||||
strokeWidth={4}
|
||||
strokeDasharray="10"
|
||||
strokeLinecap="round"
|
||||
/>
|
||||
<Group>
|
||||
{data.map((d, idx) => {
|
||||
const barName = `${getCategory(d)}-${idx}`;
|
||||
const barLength = valuePoint(d);
|
||||
const barWidth = categoryScale.bandwidth();
|
||||
return (
|
||||
<Group className={styles.barGroup} key={`bar-${barName}`}>
|
||||
<Bar
|
||||
className={styles.bar}
|
||||
x={0}
|
||||
y={categoryPoint(d)}
|
||||
width={barLength}
|
||||
height={barWidth}
|
||||
/>
|
||||
<Text
|
||||
className={styles.barText}
|
||||
x={valuePoint(d) - 12}
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
y={categoryPoint(d)! + barWidth / 2}
|
||||
fontSize={hoverLabelSize ?? barWidth * 0.75}
|
||||
textAnchor="end"
|
||||
verticalAnchor="middle"
|
||||
>
|
||||
{getValue(d)}
|
||||
</Text>
|
||||
</Group>
|
||||
);
|
||||
})}
|
||||
</Group>
|
||||
</Group>
|
||||
<AxisLeft
|
||||
scale={categoryScale}
|
||||
top={margin.top}
|
||||
left={margin.left}
|
||||
hideAxisLine
|
||||
hideTicks
|
||||
tickLabelProps={() => {
|
||||
return {
|
||||
...leftTickLabelProps(),
|
||||
className: styles.tickLabel,
|
||||
dx: "-0.5rem",
|
||||
dy: "0.25rem",
|
||||
fontSize: `${categoryTickLabelSize / 16}rem`,
|
||||
};
|
||||
}}
|
||||
label={categoryAxisLabel}
|
||||
labelClassName={styles.axisLabel}
|
||||
labelOffset={categoryAxisLabelOffset}
|
||||
labelProps={{
|
||||
fontSize: `${categoryAxisLabelSize / 16}rem`,
|
||||
}}
|
||||
/>
|
||||
<AxisBottom
|
||||
scale={valueScale}
|
||||
top={margin.top + categoryMax}
|
||||
left={margin.left}
|
||||
hideAxisLine
|
||||
hideTicks
|
||||
numTicks={5}
|
||||
tickLabelProps={() => {
|
||||
return {
|
||||
...bottomTickLabelProps(),
|
||||
className: styles.tickLabel,
|
||||
dy: "0.25rem",
|
||||
fontSize: `${valueTickLabelSize / 16}rem`,
|
||||
};
|
||||
}}
|
||||
label={valueAxisLabel}
|
||||
labelClassName={styles.axisLabel}
|
||||
labelOffset={valueAxisLabelOffset}
|
||||
labelProps={{
|
||||
fontSize: `${valueAxisLabelSize / 16}rem`,
|
||||
}}
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function BarGraphVertical(props: BarGraphProps) {
|
||||
const {
|
||||
width,
|
||||
height,
|
||||
margin,
|
||||
data,
|
||||
className,
|
||||
categoryTickLabelSize = DEFAULT_LABEL_SIZE,
|
||||
valueTickLabelSize = DEFAULT_LABEL_SIZE,
|
||||
hoverLabelSize,
|
||||
categoryAxisLabel,
|
||||
categoryAxisLabelSize = DEFAULT_LABEL_SIZE,
|
||||
categoryAxisLabelOffset = 0,
|
||||
valueAxisLabel,
|
||||
valueAxisLabelSize = DEFAULT_LABEL_SIZE,
|
||||
valueAxisLabelOffset = 0,
|
||||
} = props;
|
||||
|
||||
const barPadding = 0.4;
|
||||
|
||||
const categoryMax = width - margin.left - margin.right;
|
||||
const valueMax = height - margin.top - margin.bottom;
|
||||
|
||||
const getCategory = (d: BarGraphData) => d.category;
|
||||
const getValue = (d: BarGraphData) => d.value;
|
||||
|
||||
const categoryScale = scaleBand({
|
||||
range: [0, categoryMax],
|
||||
domain: data.map(getCategory),
|
||||
padding: barPadding,
|
||||
});
|
||||
|
||||
const valueScale = scaleLinear({
|
||||
range: [valueMax, 0],
|
||||
nice: true,
|
||||
domain: [0, Math.max(...data.map(getValue))],
|
||||
});
|
||||
|
||||
const categoryPoint = (d: BarGraphData) => categoryScale(getCategory(d));
|
||||
const valuePoint = (d: BarGraphData) => valueScale(getValue(d));
|
||||
|
||||
return (
|
||||
<svg className={className} width={width} height={height}>
|
||||
<Group top={margin.top} left={margin.left}>
|
||||
<Group>
|
||||
{data.map((d, idx) => {
|
||||
const barName = `${getCategory(d)}-${idx}`;
|
||||
const barWidth = categoryScale.bandwidth();
|
||||
const backgroundBarWidth = barWidth / (1 - barPadding);
|
||||
return idx % 2 === 0 ? (
|
||||
<Bar
|
||||
className={styles.barBackground}
|
||||
key={`bar-${barName}-background`}
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
x={categoryPoint(d)! - (backgroundBarWidth - barWidth) / 2}
|
||||
y={0}
|
||||
width={backgroundBarWidth}
|
||||
height={valueMax}
|
||||
/>
|
||||
) : null;
|
||||
})}
|
||||
</Group>
|
||||
<GridRows
|
||||
scale={valueScale}
|
||||
width={categoryMax}
|
||||
numTicks={5}
|
||||
stroke={Color.label}
|
||||
strokeWidth={4}
|
||||
strokeDasharray="10"
|
||||
strokeLinecap="round"
|
||||
/>
|
||||
<Group>
|
||||
{data.map((d, idx) => {
|
||||
const barName = `${getCategory(d)}-${idx}`;
|
||||
const barHeight = valueMax - valuePoint(d);
|
||||
const barWidth = categoryScale.bandwidth();
|
||||
return (
|
||||
<Group className={styles.barGroup} key={`bar-${barName}`}>
|
||||
<Bar
|
||||
className={styles.bar}
|
||||
x={categoryPoint(d)}
|
||||
y={valueMax - barHeight}
|
||||
width={barWidth}
|
||||
height={barHeight}
|
||||
/>
|
||||
<Text
|
||||
className={styles.barText}
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
x={categoryPoint(d)! + barWidth / 2}
|
||||
y={valueMax - barHeight + 12}
|
||||
fontSize={hoverLabelSize ?? barWidth * 0.5}
|
||||
textAnchor="middle"
|
||||
verticalAnchor="start"
|
||||
>
|
||||
{getValue(d)}
|
||||
</Text>
|
||||
</Group>
|
||||
);
|
||||
})}
|
||||
</Group>
|
||||
</Group>
|
||||
<AxisBottom
|
||||
scale={categoryScale}
|
||||
top={valueMax + margin.top}
|
||||
left={margin.left}
|
||||
hideAxisLine
|
||||
hideTicks
|
||||
tickLabelProps={() => {
|
||||
return {
|
||||
...bottomTickLabelProps(),
|
||||
className: styles.tickLabel,
|
||||
dy: "-0.25rem",
|
||||
fontSize: `${categoryTickLabelSize / 16}rem`,
|
||||
width: categoryScale.bandwidth(),
|
||||
verticalAnchor: "start",
|
||||
};
|
||||
}}
|
||||
label={categoryAxisLabel}
|
||||
labelClassName={styles.axisLabel}
|
||||
labelOffset={categoryAxisLabelOffset}
|
||||
labelProps={{
|
||||
fontSize: `${categoryAxisLabelSize / 16}rem`,
|
||||
}}
|
||||
/>
|
||||
<AxisLeft
|
||||
scale={valueScale}
|
||||
top={margin.top}
|
||||
left={margin.left}
|
||||
hideAxisLine
|
||||
hideTicks
|
||||
numTicks={5}
|
||||
tickLabelProps={() => {
|
||||
return {
|
||||
...leftTickLabelProps(),
|
||||
className: styles.tickLabel,
|
||||
dx: "-0.5rem",
|
||||
dy: "0.25rem",
|
||||
fontSize: `${valueTickLabelSize / 16}rem`,
|
||||
};
|
||||
}}
|
||||
label={valueAxisLabel}
|
||||
labelClassName={styles.axisLabel}
|
||||
labelOffset={valueAxisLabelOffset}
|
||||
labelProps={{
|
||||
fontSize: `${valueAxisLabelSize / 16}rem`,
|
||||
}}
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
.box {
|
||||
width: calc(100rem / 16);
|
||||
height: calc(100rem / 16);
|
||||
margin-bottom: calc(10rem / 16);
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
margin: calc(10rem / 16) calc(60rem / 16);
|
||||
width: calc(150rem / 16);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
import React from "react";
|
||||
import { Color } from "utils/Color";
|
||||
|
||||
import styles from "./ColorPalette.module.css";
|
||||
|
||||
export function ColorPalette() {
|
||||
return (
|
||||
<>
|
||||
<h2>Color Palette</h2>
|
||||
<div className={styles.wrapper}>
|
||||
{Object.entries(Color).map(([colorName, colorCSSName]) => (
|
||||
<div key={colorName} className={styles.item}>
|
||||
<div
|
||||
className={styles.box}
|
||||
style={{ backgroundColor: colorCSSName }}
|
||||
key={colorName}
|
||||
/>
|
||||
<span>{colorName}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
.word:hover {
|
||||
text-shadow: var(--primary-accent) 0 0 calc(20rem / 16);
|
||||
text-anchor: "middle";
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
font-family: "Inconsolata", monospace;
|
||||
font-weight: bold;
|
||||
top: 0;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
background-color: var(--label);
|
||||
color: var(--primary-background);
|
||||
box-shadow: 0px calc(1rem / 16) calc(2rem / 16) var(--card-background);
|
||||
pointer-events: none;
|
||||
padding: calc(10rem / 16);
|
||||
font-size: calc(18rem / 16);
|
||||
border-radius: calc(10rem / 16);
|
||||
}
|
|
@ -0,0 +1,210 @@
|
|||
import { localPoint } from "@visx/event";
|
||||
import { Point } from "@visx/point";
|
||||
import { scaleLog } from "@visx/scale";
|
||||
import { Text } from "@visx/text";
|
||||
import { TooltipWithBounds, useTooltip, withTooltip } from "@visx/tooltip";
|
||||
import { Wordcloud as VisxWordcloud } from "@visx/wordcloud";
|
||||
import React from "react";
|
||||
import { Color } from "utils/Color";
|
||||
|
||||
import styles from "./WordCloud.module.css";
|
||||
|
||||
interface WordCloudProps {
|
||||
data: Array<WordData>;
|
||||
/** Width of the graph, in px */
|
||||
width?: number;
|
||||
/** Height of the graph, in px */
|
||||
height?: number;
|
||||
/** Minimum padding between words, in px */
|
||||
wordPadding?: number;
|
||||
/** Weight of the font of the words */
|
||||
fontWeight?: number;
|
||||
/** The desired font size of the smallest word, in px.*/
|
||||
minFontSize?: number;
|
||||
/** The desired font size of the largest word, in px. */
|
||||
maxFontSize?: number;
|
||||
/** A random seed in the range [0, 1) used for placing the words, change this value to get an alternate placement of words */
|
||||
randomSeed?: number;
|
||||
/** Type of spiral used for rendering the words, either rectangular or archimedean */
|
||||
spiral?: "rectangular" | "archimedean";
|
||||
/** ClassName of the wrapper of the wordcloud */
|
||||
className?: string;
|
||||
}
|
||||
|
||||
interface WordData {
|
||||
text: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
const wordColors = [Color.primaryAccent, Color.primaryAccentLight];
|
||||
const TOOLTIP_HORIZONTAL_SHIFT_SCALER = 12.0;
|
||||
|
||||
export const WordCloud = withTooltip(
|
||||
({
|
||||
data,
|
||||
width,
|
||||
height,
|
||||
wordPadding,
|
||||
fontWeight,
|
||||
minFontSize,
|
||||
maxFontSize,
|
||||
randomSeed,
|
||||
spiral,
|
||||
className,
|
||||
}: WordCloudProps) => {
|
||||
const {
|
||||
tooltipData,
|
||||
tooltipLeft,
|
||||
tooltipTop,
|
||||
tooltipOpen,
|
||||
showTooltip,
|
||||
hideTooltip,
|
||||
} = useTooltip<WordData>();
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<WordCloudWordsMemoized
|
||||
width={width}
|
||||
height={height}
|
||||
data={data}
|
||||
wordPadding={wordPadding}
|
||||
fontWeight={fontWeight}
|
||||
minFontSize={minFontSize}
|
||||
maxFontSize={maxFontSize}
|
||||
showTooltip={(data, left, top) => {
|
||||
showTooltip({
|
||||
tooltipData: data,
|
||||
tooltipLeft: left,
|
||||
tooltipTop: top,
|
||||
});
|
||||
}}
|
||||
hideTooltip={hideTooltip}
|
||||
tooltipLeft={tooltipLeft}
|
||||
tooltipTop={tooltipTop}
|
||||
randomSeed={randomSeed}
|
||||
spiral={spiral}
|
||||
/>
|
||||
|
||||
{tooltipOpen && tooltipData ? (
|
||||
<TooltipWithBounds
|
||||
// set this to random so it correctly updates with parent bounds
|
||||
key={Math.random()}
|
||||
top={tooltipTop}
|
||||
left={tooltipLeft}
|
||||
className={styles.tooltip}
|
||||
unstyled
|
||||
applyPositionStyle
|
||||
>
|
||||
{tooltipData.text} ({tooltipData.value})
|
||||
</TooltipWithBounds>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
/** The internal wordcloud component that actually lays out the word needs to be separate from the tooltip to prevent extra rerendering. */
|
||||
type WordCloudWordsProps = Omit<WordCloudProps, "className"> & {
|
||||
showTooltip: (
|
||||
data: WordData,
|
||||
tooltipLeft: number,
|
||||
tooltipTop: number
|
||||
) => void;
|
||||
hideTooltip: () => void;
|
||||
// tooltipLeft and tooltipTop are used for preventing unnessary renders
|
||||
tooltipLeft?: number;
|
||||
tooltipTop?: number;
|
||||
};
|
||||
const WordCloudWords: React.FC<WordCloudWordsProps> = ({
|
||||
data,
|
||||
width = 1000,
|
||||
height = 500,
|
||||
wordPadding = 30,
|
||||
fontWeight = 500,
|
||||
minFontSize = 20,
|
||||
maxFontSize = 150,
|
||||
randomSeed = 0.5,
|
||||
spiral = "rectangular",
|
||||
showTooltip,
|
||||
hideTooltip,
|
||||
}) => {
|
||||
const fontScale = scaleLog({
|
||||
domain: [
|
||||
Math.min(...data.map((w) => w.value)),
|
||||
Math.max(...data.map((w) => w.value)),
|
||||
],
|
||||
range: [minFontSize, maxFontSize],
|
||||
});
|
||||
const fontSizeSetter = (datum: WordData) => fontScale(datum.value);
|
||||
const fixedValueGenerator = () => randomSeed;
|
||||
return (
|
||||
<VisxWordcloud
|
||||
words={data}
|
||||
width={width}
|
||||
height={height}
|
||||
fontSize={fontSizeSetter}
|
||||
font="Inconsolata, monospace"
|
||||
padding={wordPadding}
|
||||
spiral={spiral}
|
||||
rotate={0}
|
||||
random={fixedValueGenerator}
|
||||
>
|
||||
{(cloudWords) =>
|
||||
cloudWords.map((word, index) => {
|
||||
return (
|
||||
<Text
|
||||
key={`wordcloud-word-${word.text ?? ""}-${index}`}
|
||||
fill={wordColors[index % wordColors.length]}
|
||||
transform={`translate(${word.x ?? 0}, ${word.y ?? 0})`}
|
||||
fontSize={word.size}
|
||||
fontFamily={word.font}
|
||||
fontWeight={fontWeight}
|
||||
className={styles.word}
|
||||
textAnchor="middle"
|
||||
onMouseMove={
|
||||
((e: React.MouseEvent<SVGTextElement, MouseEvent>) => {
|
||||
const eventSvgCoords = localPoint(
|
||||
// ownerSVGElement is given by visx docs but not recognized by typescript
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
e.target.ownerSVGElement as Element,
|
||||
e
|
||||
) as Point;
|
||||
|
||||
if (word.text) {
|
||||
showTooltip(
|
||||
{ text: word.text, value: data[index].value },
|
||||
eventSvgCoords.x -
|
||||
word.text.length * TOOLTIP_HORIZONTAL_SHIFT_SCALER,
|
||||
eventSvgCoords.y
|
||||
);
|
||||
}
|
||||
}) as React.MouseEventHandler<SVGTextElement>
|
||||
}
|
||||
onMouseLeave={(_) => hideTooltip()}
|
||||
>
|
||||
{word.text}
|
||||
</Text>
|
||||
);
|
||||
})
|
||||
}
|
||||
</VisxWordcloud>
|
||||
);
|
||||
};
|
||||
|
||||
const shouldNotRerender = (
|
||||
prevProps: WordCloudWordsProps,
|
||||
nextProps: WordCloudWordsProps
|
||||
) => {
|
||||
if (
|
||||
prevProps.tooltipLeft !== nextProps.tooltipLeft ||
|
||||
prevProps.tooltipTop !== nextProps.tooltipTop ||
|
||||
nextProps.tooltipLeft === undefined ||
|
||||
nextProps.tooltipTop === undefined
|
||||
) {
|
||||
return true; // do not re-render
|
||||
}
|
||||
return false; // will re-render
|
||||
};
|
||||
|
||||
const WordCloudWordsMemoized = React.memo(WordCloudWords, shouldNotRerender);
|
|
@ -35,6 +35,10 @@ export const mockCategoricalData = [
|
|||
value: 29,
|
||||
},
|
||||
];
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> main
|
||||
export const moreMockCategoricalData = [
|
||||
{ key: "Python", value: 29.53 },
|
||||
{ key: "Java", value: 17.06 },
|
||||
|
@ -63,6 +67,7 @@ export const moreMockCategoricalData = [
|
|||
{ key: "Ada", value: 2.21 },
|
||||
{ key: "Dart", value: 2.21 },
|
||||
];
|
||||
<<<<<<< HEAD
|
||||
|
||||
export const mockLineGraphlData = [
|
||||
{
|
||||
|
@ -90,3 +95,5 @@ export const mockLineGraphlData = [
|
|||
y: 80,
|
||||
},
|
||||
];
|
||||
=======
|
||||
>>>>>>> main
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
## Setting up CI
|
||||
|
||||
- Follow instructions on [CSC cloud](https://docs.cloud.csclub.uwaterloo.ca/kubernetes/) to setup csccloud.
|
||||
- Setup the repository to store your docker images on [CSC Harbour](https://docs.cloud.csclub.uwaterloo.ca/registry/).
|
||||
- Make sure to add harbour auth tokens to drone. Click the my profile page on harbour, and set HARBOUR_USERNAME and HARBOUR_PASSWORD on drone secrets to the username and cli secret from the harbour profile page.
|
||||
- Clone the [server repo](https://git.csclub.uwaterloo.ca/snedadah/csc-webhooks), fill in desired links, update env file with the auth token, update STAGING_AUTH_TOKEN in drone to match. Run `npm start` to start server in the background.
|
||||
- Possibly put a crontab to restart the script on [startup](https://stackoverflow.com/questions/12973777/how-to-run-a-shell-script-at-startup)
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
trailingSlash: true,
|
||||
}
|
||||
|
||||
module.exports = nextConfig
|
||||
|
|
|
@ -64,7 +64,7 @@ body {
|
|||
|
||||
background-color: var(--primary-background);
|
||||
color: var(--primary-text);
|
||||
font-family: "Inconsolata", "monospace";
|
||||
font-family: "Inconsolata", monospace;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
|
@ -109,4 +109,4 @@ a:hover {
|
|||
--card-background: var(--dark--card-background);
|
||||
--label: var(--dark--label);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
font-weight: 200;
|
||||
src: local(''),
|
||||
url('../public/fonts/inconsolata-v30-latin-200.woff2') format('woff2'),
|
||||
url('../public/fonts/inconsolata-v30-latin-200.woff') format('woff'),
|
||||
url('../public/fonts/inconsolata-v30-latin-200.woff') format('woff');
|
||||
}
|
||||
|
||||
/* inconsolata-300 - latin */
|
||||
|
@ -15,7 +15,7 @@
|
|||
font-weight: 300;
|
||||
src: local(''),
|
||||
url('../public/fonts/inconsolata-v30-latin-300.woff2') format('woff2'),
|
||||
url('../public/fonts/inconsolata-v30-latin-300.woff') format('woff'),
|
||||
url('../public/fonts/inconsolata-v30-latin-300.woff') format('woff');
|
||||
}
|
||||
|
||||
/* inconsolata-regular - latin */
|
||||
|
@ -25,7 +25,7 @@
|
|||
font-weight: 400;
|
||||
src: local(''),
|
||||
url('../public/fonts/inconsolata-v30-latin-regular.woff2') format('woff2'),
|
||||
url('../public/fonts/inconsolata-v30-latin-regular.woff') format('woff'),
|
||||
url('../public/fonts/inconsolata-v30-latin-regular.woff') format('woff');
|
||||
}
|
||||
|
||||
/* inconsolata-500 - latin */
|
||||
|
@ -35,7 +35,7 @@
|
|||
font-weight: 500;
|
||||
src: local(''),
|
||||
url('../public/fonts/inconsolata-v30-latin-500.woff2') format('woff2'),
|
||||
url('../public/fonts/inconsolata-v30-latin-500.woff') format('woff'),
|
||||
url('../public/fonts/inconsolata-v30-latin-500.woff') format('woff');
|
||||
}
|
||||
|
||||
/* inconsolata-600 - latin */
|
||||
|
@ -46,7 +46,7 @@
|
|||
src: local(''),
|
||||
url('../public/fonts/inconsolata-v30-latin-600.woff2') format('woff2'),
|
||||
/* Super Modern Browsers */
|
||||
url('../public/fonts/inconsolata-v30-latin-600.woff') format('woff'),
|
||||
url('../public/fonts/inconsolata-v30-latin-600.woff') format('woff');
|
||||
}
|
||||
|
||||
/* inconsolata-700 - latin */
|
||||
|
@ -56,7 +56,7 @@
|
|||
font-weight: 700;
|
||||
src: local(''),
|
||||
url('../public/fonts/inconsolata-v30-latin-700.woff2') format('woff2'),
|
||||
url('../public/fonts/inconsolata-v30-latin-700.woff') format('woff'),
|
||||
url('../public/fonts/inconsolata-v30-latin-700.woff') format('woff');
|
||||
}
|
||||
|
||||
/* inconsolata-800 - latin */
|
||||
|
@ -66,7 +66,7 @@
|
|||
font-weight: 800;
|
||||
src: local(''),
|
||||
url('../public/fonts/inconsolata-v30-latin-800.woff2') format('woff2'),
|
||||
url('../public/fonts/inconsolata-v30-latin-800.woff') format('woff'),
|
||||
url('../public/fonts/inconsolata-v30-latin-800.woff') format('woff');
|
||||
}
|
||||
|
||||
/* inconsolata-900 - latin */
|
||||
|
@ -76,5 +76,5 @@
|
|||
font-weight: 900;
|
||||
src: local(''),
|
||||
url('../public/fonts/inconsolata-v30-latin-900.woff2') format('woff2'),
|
||||
url('../public/fonts/inconsolata-v30-latin-900.woff') format('woff'),
|
||||
}
|
||||
url('../public/fonts/inconsolata-v30-latin-900.woff') format('woff');
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
.page {
|
||||
padding: calc(8rem / 16);
|
||||
}
|
||||
|
||||
.barGraphDemo {
|
||||
border: calc(1rem / 16) solid black;
|
||||
}
|
|
@ -3,7 +3,10 @@ import { mockCategoricalData, moreMockCategoricalData } from "data/mocks";
|
|||
import React from "react";
|
||||
|
||||
import { ColorPalette } from "../components/ColorPalette";
|
||||
<<<<<<< HEAD
|
||||
import { LineGraph } from "../components/LineGraph";
|
||||
=======
|
||||
>>>>>>> main
|
||||
import { WordCloud } from "../components/WordCloud";
|
||||
|
||||
import styles from "./playground.module.css";
|
||||
|
@ -14,6 +17,10 @@ export default function Home() {
|
|||
<h1>Playground</h1>
|
||||
<p>Show off your components here!</p>
|
||||
<ColorPalette />
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> main
|
||||
<h2>
|
||||
<code>{"<BarGraphHorizontal />"}</code>
|
||||
</h2>
|
||||
|
@ -29,6 +36,10 @@ export default function Home() {
|
|||
right: 20,
|
||||
}}
|
||||
/>
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> main
|
||||
<h2>
|
||||
<code>{"<BarGraphVertical />"}</code>
|
||||
</h2>
|
||||
|
@ -48,6 +59,10 @@ export default function Home() {
|
|||
right: 20,
|
||||
}}
|
||||
/>
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> main
|
||||
<h2>
|
||||
<code>{"<WordCloud />"}</code>
|
||||
</h2>
|
||||
|
@ -57,6 +72,7 @@ export default function Home() {
|
|||
value: word.value,
|
||||
}))}
|
||||
/>
|
||||
<<<<<<< HEAD
|
||||
<h2>
|
||||
<code>{"<LineGraph />"}</code>
|
||||
</h2>
|
||||
|
@ -72,6 +88,8 @@ export default function Home() {
|
|||
right: 20,
|
||||
}}
|
||||
/>
|
||||
=======
|
||||
>>>>>>> main
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
server {
|
||||
listen 80;
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ $uri.html $uri.html/ /index.html;
|
||||
}
|
||||
error_page 404 /index.html;
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
const colorNames = [
|
||||
"primaryBackground",
|
||||
"secondaryBackground",
|
||||
"tertiaryBackground",
|
||||
"primaryAccent",
|
||||
"primaryAccentLight",
|
||||
"primaryAccentLighter",
|
||||
"secondaryAccent",
|
||||
"secondaryAccentLight",
|
||||
"primaryHeading",
|
||||
"secondaryHeading",
|
||||
"link",
|
||||
"linkHover",
|
||||
"primaryText",
|
||||
"cardBackground",
|
||||
"label",
|
||||
] as const;
|
||||
|
||||
// This type is needed for smart autocomplete
|
||||
type ColorName = typeof colorNames[number];
|
||||
|
||||
export const Color: { [key in ColorName]: string } = {
|
||||
primaryBackground: "var(--primary-background)",
|
||||
secondaryBackground: "var(--secondary-background)",
|
||||
tertiaryBackground: "var(--tertiary-background)",
|
||||
primaryAccent: "var(--primary-accent)",
|
||||
primaryAccentLight: "var(--primary-accent-light)",
|
||||
primaryAccentLighter: "var(--primary-accent-lighter)",
|
||||
secondaryAccent: "var(--secondary-accent)",
|
||||
secondaryAccentLight: "var(--secondary-accent-light)",
|
||||
primaryHeading: "var(--primary-heading)",
|
||||
secondaryHeading: "var(--secondary-heading)",
|
||||
link: "var(--link)",
|
||||
linkHover: "var(--link-hover)",
|
||||
primaryText: "var(--primary-text)",
|
||||
cardBackground: "var(--card-background)",
|
||||
label: "var(--label)",
|
||||
};
|
Loading…
Reference in New Issue