Sample page and graph wrappers #32

Merged
snedadah merged 18 commits from shahanneda/wrapper into main 2022-09-02 17:39:47 -04:00
7 changed files with 151 additions and 2 deletions
Showing only changes of commit ac446f7b07 - Show all commits

View File

@ -2,12 +2,13 @@
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.format.enable": true,
"eslint.codeActionsOnSave.mode": "all",
"css.lint.validProperties": ["composes"],
a258wang marked this conversation as resolved
Review

This is a feature that we already have, its just the linter does not know it.

This is a feature that we already have, its just the linter does not know it.
"css.format.spaceAroundSelectorSeparator": true,
"[css]": {
"editor.suggest.insertMode": "replace",
"gitlens.codeLens.scopes": ["document"],
"editor.formatOnSave": true,
"editor.defaultFormatter": "vscode.css-language-features"
"editor.defaultFormatter": "vscode.css-language-features",
},
"[javascript]": {
"editor.formatOnSave": false,

View File

@ -0,0 +1,32 @@
.wrapperCommon {
background-color: var(--secondary-background);
display: flex;
width: 80%;
padding: calc(40rem / 16) calc(50rem / 16);
margin: calc(80rem / 16) 0;
}
.wrapperRight {
composes: wrapperCommon;
align-self: end;
margin-right: 0;
padding-right: 0;
border-radius: calc(200rem / 16) 0 0 calc(200rem / 16);
}
.wrapperLeft {
composes: wrapperCommon;
align-self: start;
margin-left: 0;
padding-left: 0;
border-radius: 0 12.5rem 12.5rem 0;
}
.graphWrapper {
margin: calc(20rem / 16);
}
.textWrapper {
margin: 0 calc(100rem / 16);
}

View File

@ -0,0 +1,27 @@
import React from "react";
import styles from "./SideComponentWrapper.module.css";
type ComponentWrapperProps = {
children: React.ReactNode;
heading: string;
body: string;
rightAligned?: boolean;
};
export default function SideComponentWrapper({
heading,
body,
children,
rightAligned = false,
}: ComponentWrapperProps) {
return (
<div className={rightAligned ? styles.wrapperRight : styles.wrapperLeft}>
<div className={styles.graphWrapper}>{children}</div>
<div className={styles.textWrapper}>
<h3 className={styles.heading}>{heading}</h3>
<p className={styles.body}>{body}</p>
</div>
</div>
);
}

View File

@ -73,7 +73,11 @@ h2 {
color: var(--primary-heading);
}
h3,
h3 {
color: var(--secondary-heading);
font-size: calc(45rem / 16);
}
h4,
h5,
h6 {
@ -89,6 +93,10 @@ a:hover {
color: var(--link-hover);
}
p {
font-size: calc(28rem / 16);
a258wang marked this conversation as resolved
Review

This font is so big 😂 Let's create an issue to standardize the font sizes to be reasonable across the site

Edit: #33

This font is so big 😂 Let's create an issue to standardize the font sizes to be reasonable across the site Edit: #33
Review

Leaving it as it is for now, we can handle it later in that issue.

Leaving it as it is for now, we can handle it later in that issue.
}
@media only screen and (prefers-color-scheme: dark) {
body {
--primary-background: var(--dark--primary-background);

View File

@ -2,6 +2,8 @@ import { BarGraphHorizontal, BarGraphVertical } from "components/BarGraph";
import { mockCategoricalData, moreMockCategoricalData } from "data/mocks";
import React from "react";
import SideComponentWrapper from "@/components/SideComponentWrapper";
import { ColorPalette } from "../components/ColorPalette";
import { WordCloud } from "../components/WordCloud";
@ -59,6 +61,36 @@ export default function Home() {
value: word.value,
}))}
/>
<SideComponentWrapper
heading="What program are you in?"
body="There are a total of 106 respondents of the CS Class Profile. Interestingly, there are a huge number of students that are just in CS, partially due to the overwhelming number of people in CS as seen in the total demographics."
>
<BarGraphVertical
data={mockCategoricalData}
width={800}
height={500}
margin={{
top: 20,
bottom: 80,
left: 60,
right: 20,
}}
/>
</SideComponentWrapper>
<SideComponentWrapper
heading="What program are you in?"
body="There are a total of 106 respondents of the CS Class Profile. Interestingly, there are a huge number of students that are just in CS, partially due to the overwhelming number of people in CS as seen in the total demographics."
rightAligned
>
<WordCloud
data={moreMockCategoricalData.map((word) => ({
text: word.key,
value: word.value,
}))}
/>
</SideComponentWrapper>
</div>
);
}

View File

@ -0,0 +1,4 @@
.page {
display: flex;
Review

Would be nice to not have to have the page be a flexbox, but I think I'm just being picky at this point LOL

(But if we're really sticking to a flex-direction column flexbox, maybe also consider setting justify-content: center)

Would be nice to not have to have the page be a flexbox, but I think I'm just being picky at this point LOL (But if we're really sticking to a flex-direction column flexbox, maybe also consider setting `justify-content: center`)
Review

Is there a reason for not using flexbox? The alternative is to use "float:right", on the bubbles, instead of "align-self: end", so I just stuck with making everything flex.

Is there a reason for not using flexbox? The alternative is to use "float:right", on the bubbles, instead of "align-self: end", so I just stuck with making everything flex.
Review

My rationale for trying to avoid flexbox here is that this imposes an additional requirement on the outer container, which is separate from the Wrapper component... so inevitably someone someday is going to try to use the Wrapper component and be like "wHy DoEsN't ThIs WoRk?!!!" because they forgot to set display: flex and flex-direction: column on the outer container.

The alternative to both flexbox and float is what's used on the website: the Bubble component consists of a relatively positioned "container" with an absolutely positioned "bar" (what we see as the "bubble") that's translated sideways and cut off at the edge of the screen. This way, devs don't need to remember to do anything extra when using the component, because everything that's required for the component to work properly is an internal detail.

My rationale for trying to avoid flexbox here is that this imposes an additional requirement on the outer container, which is separate from the Wrapper component... so inevitably someone someday is going to try to use the Wrapper component and be like "wHy DoEsN't ThIs WoRk?!!!" because they forgot to set `display: flex` and `flex-direction: column` on the outer container. The alternative to both flexbox and float is what's used on the website: the Bubble component consists of a relatively positioned "container" with an absolutely positioned "bar" (what we see as the "bubble") that's translated sideways and cut off at the edge of the screen. This way, devs don't need to remember to do anything extra when using the component, because everything that's required for the component to work properly is an internal detail.
Review

Yep, I did see the way it was done in the website, however since this technique is quite different than that I don't think it's worth it to restart using that approach, considering that the issue you outlined is not that likely that severe (only us using these components) and the scope of this project isn't really that big.

Yep, I did see the way it was done in the website, however since this technique is quite different than that I don't think it's worth it to restart using that approach, considering that the issue you outlined is not that likely that severe (only us using these components) and the scope of this project isn't really that big.
flex-direction: column;
}

45
pages/samplePage.tsx Normal file
View File

@ -0,0 +1,45 @@
import { BarGraphVertical } from "components/BarGraph";
import { mockCategoricalData, moreMockCategoricalData } from "data/mocks";
import React from "react";
import SideComponentWrapper from "@/components/SideComponentWrapper";
import { WordCloud } from "../components/WordCloud";
import styles from "./samplePage.module.css";
export default function SamplePage() {
return (
<div className={styles.page}>
<SideComponentWrapper
heading="What program are you in?"
body="There are a total of 106 respondents of the CS Class Profile. Interestingly, there are a huge number of students that are just in CS, partially due to the overwhelming number of people in CS as seen in the total demographics."
>
<BarGraphVertical
data={mockCategoricalData}
width={800}
height={500}
margin={{
top: 20,
bottom: 80,
left: 60,
right: 20,
}}
/>
</SideComponentWrapper>
<SideComponentWrapper
heading="What program are you in?"
body="There are a total of 106 respondents of the CS Class Profile. Interestingly, there are a huge number of students that are just in CS, partially due to the overwhelming number of people in CS as seen in the total demographics."
rightAligned
>
<WordCloud
data={moreMockCategoricalData.map((word) => ({
text: word.key,
value: word.value,
}))}
/>
</SideComponentWrapper>
</div>
);
}