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

feat: Add mobile responsiveness to organisms and dashboard #81

Merged
merged 17 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
b753877
Starting work to add mobile responsiveness.
chadstewart Jul 19, 2022
141028a
Some clean up of tailwind styles and minor mobile responsiveness upda…
chadstewart Jul 19, 2022
6dd66e7
Removed space-between on highlight card and replaced with margins.
chadstewart Jul 19, 2022
98f6af1
Adjusted Highlight card width to be percentages as opposed to a fixed…
chadstewart Jul 19, 2022
5498080
Added mobile responsiveness to Top Nav. Need to look into mobile resp…
chadstewart Jul 19, 2022
e0f422e
Added mobile responsiveness for Header and added a temporary responsi…
chadstewart Jul 19, 2022
abe73f8
Updating mobile responsiveness for previously worked on components an…
chadstewart Jul 19, 2022
6ba02cb
Added mobile responsiveness to tools display. Need to think about the…
chadstewart Jul 19, 2022
b608ab3
Made some adjustments to tools display to accomodate for tablet design.
chadstewart Jul 19, 2022
eab2032
Added truncation to row title when screen size is small. Playing arou…
chadstewart Jul 19, 2022
a9d12b3
Removed drop shadow from Card component.
chadstewart Jul 19, 2022
2ddb116
Made nav scrollable on overflow.
chadstewart Jul 19, 2022
895d084
Made minor change to replace padding in top nav after 768px width.
chadstewart Jul 19, 2022
26afc3e
Added jest to project and added test for truncateString.
chadstewart Jul 19, 2022
fae2ede
Adjusted card to fit two cards at a time in certain screen sizes.
chadstewart Jul 19, 2022
8c219e9
Updated test case to show when truncateString shouldn't truncate a st…
chadstewart Jul 19, 2022
53f82ea
Updated folder structure of test.
chadstewart Jul 19, 2022
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 components/atoms/Card/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface CardProps {

const Card: React.FC<CardProps> = ({ className, children }) => {
return (
<div className={`${className && className} block p-6 bg-white rounded-lg border border-gray-200 shadow-md`}>
<div className={`${className && className} block p-6 bg-white rounded-lg border border-slate-300`}>
{children}
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions components/molecules/AuthSection/auth-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { Divider } from "@supabase/ui";
const AuthSection: React.FC = () => {
return (
<div className="flex">
<div className="flex items-center gap-3">
<div className="flex items-center gap-2 lg:gap-3">
<OnboardingButton />
<Divider type="vertical" className="!h-6 !bg-gray-600"></Divider>
<Image alt="Notification Icon" src={notifications} />
<div className="flex gap-2">
<div className="flex gap-2 lg:gap-2">
<Avatar alt="User Avatar" avatarURL={userAvatar} size={"base"} hasBorder={true} />
<Image alt="Down Arrow" src={downArrow}/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/molecules/HeaderLogo/header-logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const HeaderLogo: React.FC = () => {
return (
<div className="flex items-center p-2">
<Image className="rounded" alt="Open Sauced Logo" width={32} height={32} src={openSaucedImg} />
<Text className="font-semibold px-2 text-[16px] !text-white">OpenSauced</Text>
<Text className="font-semibold px-2 text-[16px] hidden xs:block !text-white">OpenSauced</Text>
</div>
);
};
Expand Down
5 changes: 3 additions & 2 deletions components/molecules/HighlightCard/highlight-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import thumbsIcon from "../../../public/icons/icon-thumbs-down--yellow.svg";
import metricArrow from "../../../public/icons/metric-arrow.svg";

interface HighlightCardProps {
className?: string;
label?: string;
icon?: "participation" | "accepted-pr" | "unlabeled-pr" | "spam";
metricIncreases: boolean;
Expand Down Expand Up @@ -38,9 +39,9 @@ const icons = {
}
};

const HighlightCard: React.FC<HighlightCardProps> = ({ label, icon, metricIncreases, increased, numChanged, percentage, percentageLabel }) => {
const HighlightCard: React.FC<HighlightCardProps> = ({ className, label, icon, metricIncreases, increased, numChanged, percentage, percentageLabel }) => {
return (
<div className="flex flex-col bg-white border border-slate-300 rounded-lg min-w-[316px] max-w-md h-auto p-2">
<div className={`${className && className} flex flex-col bg-white border border-slate-300 rounded-lg min-w-[316px] max-w-md h-auto p-2`}>
{/* Top Information */}
<div className="flex justify-between w-full p-1">
{/* Label */}
Expand Down
5 changes: 3 additions & 2 deletions components/molecules/SelectableTable/selectable-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import StarIcon from "public/icons/star-icon.svg";
import Person from "public/icons/person.svg";
import Icon3 from "public/icons/icon3.svg";
import ComponentHeader from "../ComponentHeader/component-header";
import { truncateString } from "../../../lib/funcs/truncate-string";

type ParticipantsRow = {
title: string;
Expand Down Expand Up @@ -60,9 +61,9 @@ const SelectableTable: React.FC<SelectableTableProps> = ({ title, tableType, row
<tr className="h-3"></tr>
{rows?.map((row, index) => {
return (
<tr key={index}>
<tr className={`hover:content-['${row.title}']`} key={index}>
<td className="flex flex-row text-left p-2">
<Checkbox label=""/> {row.title}
<Checkbox label=""/> {window.innerWidth < 425 ? truncateString(row.title, 3) : row.title}
</td>
<td className="text-right p-2">
{row.stars}%
Expand Down
34 changes: 19 additions & 15 deletions components/organisms/ToolsDisplay/tools-display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ const Tool: React.FC = () => {
<div className="flex flex-col w-full">
{tool === "Dashboard" ?
<>
<div className="flex justify-between max-w-full mb-10">
<HighlightCard
<div className="flex flex-col items-center lg:flex-row max-w-full mb-10">
<HighlightCard
className="mb-4 lg:mb-0 lg:mr-3 lg:min-w-[24.3%]"
chadstewart marked this conversation as resolved.
Show resolved Hide resolved
label="Participation"
icon="participation"
metricIncreases={true}
increased={true}
numChanged={38}
percentage={42}
percentage={40}
percentageLabel="of 49,999"
/>
<HighlightCard
<HighlightCard
className="mb-4 lg:mb-0 lg:mr-3 lg:min-w-[24.3%]"
label="Spam"
icon="spam"
metricIncreases={false}
Expand All @@ -34,43 +36,45 @@ const Tool: React.FC = () => {
percentage={80}
percentageLabel="of 49,999"
/>
<HighlightCard
<HighlightCard
className="mb-4 lg:mb-0 lg:mr-3 lg:min-w-[24.3%]"
label="Accepted PRs"
icon="accepted-pr"
metricIncreases={true}
increased={false}
numChanged={38}
percentage={42}
percentage={37}
percentageLabel="of 49,999"
/>
<HighlightCard
<HighlightCard
className="mb-4 lg:mb-0 lg:min-w-[24.3%]"
label="Unlabeled PRs"
icon="unlabeled-pr"
metricIncreases={false}
increased={false}
numChanged={98}
percentage={80}
numChanged={85}
percentage={77}
percentageLabel="of 49,999"
/>
</div>
<div className="flex max-w-full mb-10">
<div className="flex flex-col w-[60%] mr-10">
<div className="flex flex-col lg:flex-row max-w-full mb-10">
<div className="flex flex-col w-full lg:w-[50%] xl:!w-[60%] mr-10">
chadstewart marked this conversation as resolved.
Show resolved Hide resolved
<Card className="w-full mb-10 p-5">
<ScatterChart title="Test Title" option={testOptions} />
</Card>
<Card className="w-full mb-10 p-5">
<ScatterChart title="Test Title" option={testOptions} />
</Card>
<div className="flex w-full h-[500px]">
<Card className="w-[50%] mr-10 h-full p-5">
<div className="flex flex-col 2xl:flex-row w-full h-auto">
<Card className="w-full mb-10 2xl:mb-0 2xl:w-[49%] xl:mr-4 h-full px-1 md:px-5 py-5">
<SelectableTable rows={testRows} title="Test Title" tableType="participants" />
</Card>
<Card className="w-[50%] h-full p-5">
<Card className="w-full mb-10 2xl:mb-0 2xl:w-[49%] h-full px-1 md:px-5 py-5">
<SelectableTable rows={testRows} title="Test Title" tableType="participants" />
</Card>
</div>
</div>
<Card className="w-[40%] p-5">
<Card className="w-full lg:w-[50%] xl:!w-[40%] px-1 md:px-5 py-5">
<SelectableTable rows={extendedTestRows} title="Test Title" tableType="participants" />
</Card>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/organisms/TopNav/top-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import HeaderLogo from "../../molecules/HeaderLogo/header-logo";

const TopNav: React.FC = () => {
return (
<div className="top-nav-container flex justify-between items-center px-16 py-0.5 bg-zinc-900 border-b">
<div className="top-nav-container flex justify-between items-center pr-1 md:px-16 py-0.5 bg-zinc-900 border-b">
<HeaderLogo />
<AuthSection />
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/organisms/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Header: React.FC = () => {
const { filterorg } = router.query;

return (
<header className="header flex flex-row pt-[24px] px-[64px] bg-slate-50">
<header className="header flex flex-col md:flex-row pt-6 px-4 md:px-16 bg-slate-50">
<div className="header-image mr-2 p-2 min-w-[130px]">
<ContextThumbnail
size={120} ContextThumbnailURL={Thumbnail.src}></ContextThumbnail>
Expand Down
4 changes: 2 additions & 2 deletions components/organisms/toolist/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Nav: React.FC<NavProps> = ({ toolList, selectedTool, portalName }) => {
aria-orientation="horizontal"
aria-label="Browse the tools"
tabIndex={0}
className="tool-list-nav flex flex-row gap-2 px-16 bg-slate-50 border-b pt-3">
className="tool-list-nav flex w-[100vw] overflow-x-auto overflow-y-hidden gap-2 px-4 md:px-16 bg-slate-50 border-b pt-3">

{toolList.map((tool, index) =>
<div
Expand All @@ -36,7 +36,7 @@ const Nav: React.FC<NavProps> = ({ toolList, selectedTool, portalName }) => {
`${portalName}?tool=${tool.name}`
}
>
<Button size="xlarge" type="text" className={`!px-4 hover:!bg-slate-100 after:block after:absolute after:inset-x-0 after:-bottom-0.5 after:h-0.5 after:rounded-lg ${selectedTool === tool.name ? "after:bg-orange-500" : "focus:after:bg-slate-400"} focus:bg-slate-100 focus:ring-slate-300 child:flex child:items-center`}>
<Button size="xlarge" type="text" className={`!px-2 md:!px-4 hover:!bg-slate-100 after:block after:absolute after:inset-x-0 after:-bottom-0.5 after:h-0.5 after:rounded-lg ${selectedTool === tool.name ? "after:bg-orange-500" : "focus:after:bg-slate-400"} focus:bg-slate-100 focus:ring-slate-300 child:flex child:items-center`}>
<span className={"text-base whitespace-nowrap " + (selectedTool === tool.name ? "text-slate-900" : "text-slate-500")}>
{tool.name}
</span>
Expand Down
12 changes: 12 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const nextJest = require("next/jest");

const createJestConfig = nextJest({
dir: "./"
});

const customJestConfig = {
moduleDirectories: ["node_modules", "<rootDir>/"]
/* testEnvironment: "jest-environment-jsdom" */
};

module.exports = createJestConfig(customJestConfig);
2 changes: 1 addition & 1 deletion layouts/portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const PortalLayout = ({children}: {children: React.ReactNode}) => {
/>
</div>

<main className="flex w-full flex-1 flex-col items-center justify-center text-center px-[64px] pt-8 pb-6">
<main className="flex w-full flex-1 flex-col items-center justify-center text-center px-3 md:px-16 pt-8 pb-6">
{children}
</main>
</div>
Expand Down
6 changes: 6 additions & 0 deletions lib/funcs/truncate-string.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function truncateString(str: string, num: number) {
if (str.length <= num) {
return str;
}
return str.slice(0, num) + "...";
};
chadstewart marked this conversation as resolved.
Show resolved Hide resolved
Loading