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

General UI & Docs Updates #56

Merged
merged 11 commits into from
Dec 2, 2023
Merged
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
10 changes: 3 additions & 7 deletions cli/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { GRAB_PATH } from '@shared/config/paths';
import { satisfies as isValidVersion } from 'semver';
import { engines } from '../../package.json';
import { generateGrabUrl as baseGenerateGrabUrl } from '@shared/lib/util';

export const generateGrabUrl = (id: string) => {
const params = new URLSearchParams({ drop: id });
const baseUrl = new URL(GRAB_PATH, process.env.DEADDROP_API_URL!);

return `${baseUrl.toString()}?${params.toString()}`;
};
export const generateGrabUrl = (id: string) =>
baseGenerateGrabUrl(process.env.DEADDROP_API_URL!, id);

export const checkNodeVersion = () => {
const neededVersion = engines.node;
Expand Down
8 changes: 8 additions & 0 deletions shared/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { GRAB_PATH } from '../config/paths';
import { randomBytes } from 'crypto';
import { customAlphabet } from 'nanoid';

Expand All @@ -20,3 +21,10 @@ export const generateId = () => customAlphabet(alphanumeric, 12)();
export const generateIV = () => randomBytes(12).toString('binary');

export const getIVBuffer = (iv: string) => Buffer.from(iv, 'binary');

export const generateGrabUrl = (url: string, id: string) => {
const params = new URLSearchParams({ drop: id });
const baseUrl = new URL(GRAB_PATH, url);

return `${baseUrl.toString()}?${params.toString()}`;
};
8 changes: 4 additions & 4 deletions web/atoms/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const Footer = () => {
<IconBrandGithub color={theme.colors.gray[5]} />
</Anchor>
<Text size={'xs'}>
Copyright &copy;{' '}
&copy; {new Date().getFullYear()} deadrop by{' '}
<Anchor href={'https://nieky.info/'} target={'_blank'}>
Nieky Allen
</Anchor>{' '}
{new Date().getFullYear()}.
Nieky
</Anchor>
.
</Text>
</BaseFooter>
);
Expand Down
38 changes: 19 additions & 19 deletions web/atoms/header/Brand.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { HOME_PATH } from '@shared/config/paths';
import { Box, Text, clsx, createStyles } from '@mantine/core';
import { Box, Title, clsx, createStyles } from '@mantine/core';
import Link from 'next/link';
import Image from 'next/image';
import { useMediaQuery } from '@mantine/hooks';
Expand All @@ -15,7 +15,7 @@ const useStyles = createStyles((theme) => ({
marginLeft: '7px',
},
headerName: {
...theme.headings.sizes.h1,
color: 'white',
fontWeight: 'bold',
float: 'left',
':hover': {
Expand All @@ -31,28 +31,28 @@ const useStyles = createStyles((theme) => ({

const Brand = () => {
const { classes } = useStyles();
const renderLogo = useMediaQuery('(min-width: 490px)');
const renderBrandName = useMediaQuery('(min-width: 505px)');

return (
<Link href={HOME_PATH}>
<Box className={classes.linkContainer}>
{renderLogo && (
<Image
src={'/icons/android-chrome-192x192.png'}
height={54}
width={54}
className={classes.hoverPointer}
/>
<Image
src={'/icons/apple-touch-icon.png'}
height={60}
width={60}
className={classes.hoverPointer}
/>
{renderBrandName && (
<Title
className={clsx(
classes.headerName,
classes.hoverPointer,
classes.logoSpacing,
)}
>
deadrop
</Title>
)}
<Text
className={clsx(
classes.headerName,
classes.hoverPointer,
renderLogo && classes.logoSpacing,
)}
>
deadrop
</Text>
</Box>
</Link>
);
Expand Down
10 changes: 3 additions & 7 deletions web/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import randomColor from 'randomcolor';
import { GRAB_PATH } from '@shared/config/paths';
import { UAParser } from 'ua-parser-js';
import { generateGrabUrl as baseGenerateGrabUrl } from '@shared/lib/util';

// ref: https://github.com/davidmerfield/randomColor#options
const hues = [
Expand All @@ -27,13 +27,9 @@ export const generateColorSet = (amount = 2) => {
};

export const generateGrabUrl = (id: string) => {
const params = new URLSearchParams({ drop: id });
const baseUrl = new URL(
GRAB_PATH,
window.location.protocol + window.location.host,
);
const url = window.location.protocol + window.location.host;

return `${baseUrl.toString()}?${params.toString()}`;
return baseGenerateGrabUrl(url, id);
};

export const formatDropKey = (id: string) => `drop:${id}`;
Expand Down
2 changes: 1 addition & 1 deletion web/mdx-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
),
blockquote: ({ children }) => <Blockquote>{children}</Blockquote>,
code: ({ children }) => (
<Code style={{ padding: theme.spacing.xs * 0.7 }}>{children}</Code>
<Code block style={{ padding: theme.spacing.sm }}>{children}</Code>
),
em: ({ children }) => (
<LargeText component={'span'} fs={'italic'}>
Expand Down
40 changes: 28 additions & 12 deletions web/molecules/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,44 @@ import {
Box,
Button,
Flex,
Group,
Loader,
Popover,
useMantineTheme,
createStyles,
} from '@mantine/core';
import Brand from 'atoms/header/Brand';
import { useUser } from '@auth0/nextjs-auth0/client';
import { useRouter } from 'next/router';
import { LOGIN_PATH, LOGOUT_PATH } from '@shared/config/paths';
import {
LOGIN_PATH,
LOGOUT_PATH,
OVERVIEW_DOCS_PATH,
} from '@shared/config/paths';
import { useMediaQuery } from '@mantine/hooks';

const useStyles = createStyles((theme) => ({
navButton: {
fontWeight: 'bold',
},
}));

const Header = () => {
const router = useRouter();
const { user, isLoading } = useUser();
const { classes, theme } = useStyles();
const isMobile = useMediaQuery(`(max-width: ${theme.breakpoints.sm}px)`);

const onLogin = () => router.push(LOGIN_PATH);

const onDocsClick = () => router.push(OVERVIEW_DOCS_PATH);

return (
<BaseHeader
height={102}
withBorder={false}
styles={(theme) => ({
root: {
padding: theme.spacing.xl,
padding: isMobile ? theme.spacing.md : theme.spacing.xl,
},
})}
>
Expand All @@ -40,14 +56,14 @@ const Header = () => {
>
<Brand />
</Box>
<Box
style={{
flex: 1,
display: 'flex',
justifyContent: 'flex-end',
alignItems: 'center',
}}
>
<Group ml={50}>
<Button
variant={'subtle'}
className={classes.navButton}
onClick={onDocsClick}
>
Docs
</Button>
{user ? (
<Popover position={'bottom-end'}>
<Popover.Target>
Expand Down Expand Up @@ -80,7 +96,7 @@ const Header = () => {
)}
</Button>
)}
</Box>
</Group>
</Flex>
</BaseHeader>
);
Expand Down
57 changes: 44 additions & 13 deletions web/molecules/HeroBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import React from 'react';
import { Title, Text, Container, Button, createStyles, Anchor } from '@mantine/core';
import {
Title,
Text,
Container,
Button,
createStyles,
Anchor,
} from '@mantine/core';
import { useRouter } from 'next/router';
import { DROP_PATH } from '@shared/config/paths';
import { TypeAnimation } from 'react-type-animation';

// based off of: https://ui.mantine.dev/category/hero

Expand All @@ -12,7 +20,7 @@ const useStyles = createStyles((theme) => ({
paddingBottom: 105,

'@media (max-width: 520px)': {
paddingTop: 80,
paddingTop: 65,
paddingBottom: 50,
},
},
Expand All @@ -22,12 +30,25 @@ const useStyles = createStyles((theme) => ({
zIndex: 1,
},

brandName: {
display: 'none',
paddingBottom: theme.spacing.xs,
color: theme.white,
fontSize: (theme.headings.sizes.h1.fontSize! as number) * 1.4,

'@media (max-width: 504px)': {
display: 'block',
},
},

brandNameDrop: {
color: theme.colors.blue['4'],
},

title: {
fontWeight: 800,
fontSize: 40,
letterSpacing: -1,
paddingLeft: theme.spacing.md,
paddingRight: theme.spacing.md,
color: theme.white,
marginBottom: theme.spacing.xs,
textAlign: 'center',
Expand Down Expand Up @@ -56,8 +77,6 @@ const useStyles = createStyles((theme) => ({
marginTop: theme.spacing.xl * 1.5,
display: 'flex',
justifyContent: 'center',
paddingLeft: theme.spacing.md,
paddingRight: theme.spacing.md,

'@media (max-width: 520px)': {
flexDirection: 'column',
Expand Down Expand Up @@ -88,18 +107,30 @@ export function HeroBanner() {
return (
<div className={classes.wrapper}>
<div className={classes.inner}>
<Title className={classes.brandName}>
dea<span className={classes.brandNameDrop}>drop</span>
</Title>
<Title className={classes.title}>
Quickly and securely share{' '}
<Text
component="span"
inherit
<TypeAnimation
sequence={[
'passwords',
2500,
'API keys',
2500,
'.env files',
2500,
'secrets',
2500,
]}
wrapper={'span'}
className={classes.highlight}
>
secrets
</Text>
speed={15}
repeat={Infinity}
/>
</Title>

<Container size={640}>
<Container size={640} p={0}>
<Text size={'lg'} className={classes.description}>
Avoid messy and unsafe methods of sharing configuration
files, keys, and credentials.
Expand Down
14 changes: 9 additions & 5 deletions web/molecules/sections/Faq.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import React from 'react';
import { Container, Title, Accordion, createStyles } from '@mantine/core';
import { Container, Accordion, createStyles } from '@mantine/core';
import { SectionTitle } from './SectionTitle';

// based off of: https://ui.mantine.dev/category/faq

const useStyles = createStyles((theme) => ({
wrapper: {
paddingTop: theme.spacing.xl * 2,
paddingBottom: theme.spacing.xl * 2,
minHeight: 580,

'@media (max-width: 520px)': {
paddingLeft: 0,
paddingRight: 0,
},
},

title: {
Expand Down Expand Up @@ -63,11 +68,10 @@ const questions = [

export function Faq() {
const { classes } = useStyles();

return (
<Container size={'sm'} className={classes.wrapper}>
<Title id={'faq-section'} align={'center'} className={classes.title}>
FAQs
</Title>
<SectionTitle label={'FAQs'} id={'faq-section'} />

<Accordion variant={'separated'} defaultValue={questions[0].id}>
{questions.map(({ id, question, answer }, index) => (
Expand Down
17 changes: 17 additions & 0 deletions web/molecules/sections/SectionTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Title, createStyles } from '@mantine/core';

const useStyles = createStyles((theme) => ({
title: {
marginBottom: theme.spacing.xl * 1.5,
},
}));

export function SectionTitle({ id, label }: { id: string; label: string }) {
const { classes } = useStyles();

return (
<Title id={id} align={'center'} className={classes.title}>
{label}
</Title>
);
}
Loading