Skip to content

Commit

Permalink
feat: clone needs
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed May 10, 2022
1 parent 64ce37f commit 7ce2f78
Show file tree
Hide file tree
Showing 14 changed files with 515 additions and 209 deletions.
24 changes: 6 additions & 18 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ module.exports = ({
** Stuff used for the SEO or some related elements, like the title, the
** github url etc.
**********************************************************************/
WEBSITE_URI: 'https://web.ycorpo.com/',
WEBSITE_NAME: 'yWeb',
WEBSITE_TITLE: 'yWeb',
WEBSITE_DESCRIPTION: 'Template used for Yearn\'s projects',
PROJECT_GITHUB_URL: 'https://github.com/yearn/yearn-template',
WEBSITE_URI: 'https://experience.yearn.system/',
WEBSITE_NAME: 'YFI Experience',
WEBSITE_TITLE: 'YFI Experience',
WEBSITE_DESCRIPTION: 'The only YFI you need',
PROJECT_GITHUB_URL: 'https://github.com/yearn/yfi-experience',

/* 🔵 - Yearn Finance **************************************************
** Some config used to control the behaviour of the web library. By
Expand All @@ -31,12 +31,10 @@ module.exports = ({
** to fetch.
** USE_PRICE_TRI_CRYPTO: should we fetch the special Tri Crypto token
** price? (require blockchain call)
** USE_FEEDBACKS: should we enable the feedback button?
**********************************************************************/
USE_WALLET: true,
USE_PRICES: true,
USE_PRICE_TRI_CRYPTO: false,
USE_FEEDBACKS: true,
CG_IDS: ['yearn-finance'],
TOKENS: [
['0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', 18, 1]
Expand All @@ -46,16 +44,6 @@ module.exports = ({
250: process.env.RPC_URL_FANTOM || 'https://rpc.ftm.tools',
42161: process.env.RPC_URL_ARBITRUM || 'https://arbitrum.public-rpc.com'
},
ALCHEMY_KEY: process.env.ALCHEMY_KEY,

FEEBACKS_TYPE: 'github',
LINEAR_OAUTH_TOKEN: process.env.LINEAR_OAUTH_TOKEN,
LINEAR_TEAM_ID: process.env.LINEAR_TEAM_ID,
LINEAR_PROJECT_NAME: process.env.LINEAR_PROJECT_NAME,

GITHUB_AUTH_TOKEN: process.env.GITHUB_AUTH_TOKEN,
GITHUB_PROJECT_OWNER: process.env.GITHUB_PROJECT_OWNER,
GITHUB_PROJECT_REPO: process.env.GITHUB_PROJECT_REPO

ALCHEMY_KEY: process.env.ALCHEMY_KEY
}
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
"lintfix": "eslint . --ext .js,.jsx,.ts,.tsx --fix"
},
"dependencies": {
"@dnd-kit/core": "^5.0.3",
"@dnd-kit/sortable": "^6.0.1",
"@dnd-kit/utilities": "^3.1.0",
"@linear/sdk": "^1.22.0",
"@yearn/web-lib": "^0.3.13",
"@yearn/web-lib": "^0.3.14",
"autoprefixer": "^10.4.7",
"axios": "^0.27.2",
"babel-loader": "^8.2.5",
Expand Down
17 changes: 2 additions & 15 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ function AppHead(): ReactElement {
<meta name={'robots'} content={'index,nofollow'} />
<meta name={'googlebot'} content={'index,nofollow'} />
<meta charSet={'utf-8'} />

<script src={'/feedback.source.js'} defer />
<script src={'/feedback.js'} defer />
<script src={'/prism.js'} />
</Head>
<DefaultSeo
title={process.env.WEBSITE_NAME}
Expand All @@ -53,7 +49,7 @@ function AppHead(): ReactElement {
description: process.env.WEBSITE_DESCRIPTION,
images: [
{
url: `${process.env.WEBSITE_URI}og.png`,
url: `${process.env.WEBSITE_URI}og.jpg`,
width: 1200,
height: 675,
alt: 'Yearn'
Expand All @@ -80,7 +76,7 @@ function AppHeader(): ReactElement {
}, [prices]);

return (
<Header>
<Header shouldUseNetworks={false} shouldUseWallets={false}>
<div className={'justify-between pr-4 w-full flex-row-center'}>
<h1>{process.env.WEBSITE_TITLE}</h1>
<div className={'hidden flex-row items-center space-x-6 md:flex'}>
Expand Down Expand Up @@ -138,15 +134,6 @@ function AppWrapper(props: AppProps): ReactElement {
title={'yWeb'}
options={navbarMenuOptions}
wrapper={<Link passHref href={''} />}>
<div className={'flex flex-col mt-auto space-y-2'}>
{
process.env.USE_FEEDBACKS ? (
<button data-feedbackfin-button className={'button-light'}>
{'Feedback'}
</button>
) : null
}
</div>
</Navbar>
</div>
</div>
Expand Down
40 changes: 0 additions & 40 deletions pages/api/feedbacks.tsx

This file was deleted.

232 changes: 132 additions & 100 deletions pages/index.tsx
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,118 +1,150 @@
import React, {ReactElement} from 'react';
import {Card, AlertBanner} from '@yearn/web-lib/components';
import React, {ReactElement} from 'react';
import Image from 'next/image';
import {Cross, Grip} from '@yearn/web-lib/icons';
import {useClientEffect, useLocalStorage} from '@yearn/web-lib/hooks';
import {Button} from '@yearn/web-lib/components';
import * as dnd_kit from '@dnd-kit/core';
import * as dnd_kit_sortable from '@dnd-kit/sortable';
import {AnimateLayoutChanges} from '@dnd-kit/sortable';
import {CSS} from '@dnd-kit/utilities';
import YEARN_APPS from 'utils/yearnApps';

function ColorBox({color, name}: {color: string, name: string}): ReactElement {
return (
<div className={'flex flex-row space-x-2'}>
<div className={`overflow-hidden relative aspect-square w-10 border border-background ${color}`} />
<b className={'my-2 text-xs'}>{name}</b>
</div>
);
}
const {DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, MeasuringStrategy} = dnd_kit;
const {arrayMove, SortableContext, sortableKeyboardCoordinates, rectSortingStrategy, useSortable, defaultAnimateLayoutChanges} = dnd_kit_sortable;

function SortableItem({item, onRemove, id, animateLayoutChanges}: {item: TAppList, onRemove: (s: string) => void, id: string, animateLayoutChanges: any}): ReactElement {
const {attributes, listeners, setNodeRef: set_nodeRef, transform, transition} = useSortable({id, animateLayoutChanges});
const style = {
transform: CSS.Transform.toString(transform),
transition,
'--opacity': 0
};

function ColorPaletteLight(): ReactElement {
return (
<div className={'mb-10 space-y-8 w-full'}>
<div className={'grid grid-cols-3 w-full'}>
<div className={'flex flex-col gap-2 w-full'}>
<h4 className={'mb-2'}>{'Background & Surface'}</h4>
<ColorBox color={'bg-background'} name={'--color-background'} />
<ColorBox color={'bg-background-variant'} name={'--color-background-variant'} />
<ColorBox color={'bg-surface'} name={'--color-surface'} />
<ColorBox color={'bg-surface-variant'} name={'--color-surface-variant'} />
<div
className={'group relative col-span-1 w-full h-full rounded-lg cursor-default'}
id={item.title}
key={item.title}
ref={set_nodeRef}
style={style}
{...attributes}>
<div id={`child_${item.title}`} className={'feature-content'}>
<div className={'flex justify-between p-4 space-x-4 w-full h-16'}>
<div className={'flex justify-center items-center space-x-2'}>
<div className={'w-6 min-w-[24px] h-6 rounded-full bg-secondary-variant'}>
<Image src={item.icon} width={24} height={24} />
</div>
<h3 className={'self-center text-base font-bold capitalize'}>{item.title}</h3>
</div>
<div className={'flex z-50 justify-center items-center space-x-2'}>
<div onClick={(): void => onRemove(item.id)}>
<Cross className={'w-4 h-4 opacity-0 group-hover:opacity-40 transition-opacity cursor-pointer'} />
</div>
<div>
<Grip
{...listeners}
className={'w-4 h-4 opacity-40 hover:opacity-100 transition-opacity cursor-grab touch-none'} />
</div>
</div>
</div>
<div className={'flex flex-col gap-2 w-full'}>
<h4 className={'mb-2'}>{'Main colors'}</h4>
<ColorBox color={'bg-primary'} name={'--color-primary'} />
<ColorBox color={'bg-primary-variant'} name={'--color-primary-variant'} />
<ColorBox color={'bg-secondary'} name={'--color-secondary'} />
<ColorBox color={'bg-secondary-variant'} name={'--color-secondary-variant'} />
<div className={'p-4 pt-0 md:p-6 md:pt-0'}>
<div className={'mb-4'}>
<p className={'text-sm text-typo-secondary'}>
{item.description}
</p>
</div>
<div className={'mt-auto'}>
<Button as={'a'} href={item.url} target={'_blank'} rel={'noreferrer'}>
{'Access app'}
</Button>
</div>
</div>
</div>
</div>
);
}

<div className={'grid grid-cols-3 w-full'}>
<div className={'flex flex-col gap-2 w-full'}>
<h4 className={'mb-2'}>{'Typo'}</h4>
<ColorBox color={'bg-typo-primary'} name={'--color-typo-primary'} />
<ColorBox color={'bg-typo-primary-variant'} name={'--color-typo-primary-variant'} />
<ColorBox color={'bg-typo-secondary'} name={'--color-typo-secondary'} />
<ColorBox color={'bg-typo-secondary-variant'} name={'--color-typo-secondary-variant'} />
<ColorBox color={'bg-typo-off'} name={'--color-typo-off'} />
type TAppList = {
id: string,
title: string,
description: string,
url: string,
icon: string
}
function DashboardPage(): ReactElement {
const [shouldRender, set_shouldRender] = React.useState(false);
const [items, set_items] = useLocalStorage('appList', YEARN_APPS);
const sensors = useSensors(
useSensor(PointerSensor),
useSensor(KeyboardSensor, {
coordinateGetter: sortableKeyboardCoordinates
})
);

</div>
<div className={'flex flex-col gap-2 w-full'}>
<h4 className={'mb-2'}>{'Icons'}</h4>
<ColorBox color={'bg-icons-primary'} name={'--color-icons-primary'} />
<ColorBox color={'bg-icons-variant'} name={'--color-icons-variant'} />
</div>
</div>
function handleDragEnd(event: any): void {
const {active, over} = event;

if (!over?.id) {
return;
}
if (active.id !== over.id) {
set_items((_items: TAppList[]): TAppList[] => {
const oldIndex = _items.findIndex((e): boolean => e.id === active.id);
const newIndex = _items.findIndex((e): boolean => e.id === over.id);
return arrayMove(_items, oldIndex, newIndex);
});
}
}

<div className={'grid grid-cols-3 w-full'}>
<div className={'flex flex-col gap-2 w-full'}>
<h4 className={'mb-2'}>{'Button filled'}</h4>
<ColorBox color={'bg-button-filled-primary'} name={'--color-button-filled-primary'} />
<ColorBox color={'bg-button-filled-variant'} name={'--color-button-filled-variant'} />
<ColorBox color={'bg-button-filled-text'} name={'--color-button-filled-text'} />
</div>
<div className={'flex flex-col gap-2 w-full'}>
<h4 className={'mb-2'}>{'Button outlined'}</h4>
<ColorBox color={'bg-button-outlined-primary'} name={'--color-button-outlined-primary'} />
<ColorBox color={'bg-button-outlined-variant'} name={'--color-button-outlined-variant'} />
<ColorBox color={'bg-button-outlined-text'} name={'--color-button-outlined-text'} />
</div>
<div className={'flex flex-col gap-2 w-full'}>
<h4 className={'mb-2'}>{'Button Disabled'}</h4>
<ColorBox color={'bg-button-disabled-primary'} name={'--color-button-disabled-primary'} />
<ColorBox color={'bg-button-disabled-variant'} name={'--color-button-disabled-variant'} />
<ColorBox color={'bg-button-disabled-text'} name={'--color-button-disabled-text'} />
</div>
</div>
function handleRemove(id: string): void {
set_items((_items: TAppList[]): TAppList[] => _items.filter((_item): boolean => _item.id !== id));
}

<div className={'grid grid-cols-3 w-full'}>
<div className={'flex flex-col gap-2 w-full'}>
<h4 className={'mb-2'}>{'Warnings'}</h4>
<ColorBox color={'bg-alert-warning-primary'} name={'--color-alert-warning-primary'} />
<ColorBox color={'bg-alert-warning-secondary'} name={'--color-alert-warning-secondary'} />
<ColorBox color={'bg-alert-warning-secondary-variant'} name={'--color-alert-warning-secondary-variant'} />
</div>
<div className={'flex flex-col gap-2 w-full'}>
<h4 className={'mb-2'}>{'Errors'}</h4>
<ColorBox color={'bg-alert-error-primary'} name={'--color-alert-error-primary'} />
<ColorBox color={'bg-alert-error-secondary'} name={'--color-alert-error-secondary'} />
<ColorBox color={'bg-alert-error-secondary-variant'} name={'--color-alert-error-secondary-variant'} />
</div>
<div className={'flex flex-col gap-2 w-full'}>
<h4 className={'mb-2'}>{'Critical'}</h4>
<ColorBox color={'bg-alert-critical-primary'} name={'--color-alert-critical-primary'} />
<ColorBox color={'bg-alert-critical-secondary'} name={'--color-alert-critical-secondary'} />
<ColorBox color={'bg-alert-critical-secondary-variant'} name={'--color-alert-critical-secondary-variant'} />
</div>
</div>
useClientEffect((): void => {
set_shouldRender(true);
}, []);

if (!shouldRender) {
return <div />;
}
const animateLayoutChanges: AnimateLayoutChanges = (args): boolean =>
args.isSorting || args.wasDragging
? defaultAnimateLayoutChanges(args)
: true;

</div>
);
}

function Index(): ReactElement {
return (
<section aria-label={'some default section'}>
<div className={'mb-4'}>
<AlertBanner
id={'color-system'}
title={'Color system'}
level={'info'}
maxHeight={'max-h-[600px] md:max-h-[300px]'}>
<div>
<p className={'text-primary'}>{'With this color system, we are trying to mimic some material standard conventions, with the use of `primary`, `secondary`, `variant`, `background`, `surface`, etc. Naming if far from perfect yet, but it\'s a Work In Progress'}</p>
<p className={'block mt-4 text-primary'}>{'The colors are set using css variables and can be overrited in your style.css file.'}</p>
</div>
</AlertBanner>
<section aria-label={'dashboard'}>
<div className={'relative w-full'}>
<div className={'features'}>
<DndContext
sensors={sensors}
collisionDetection={closestCenter}
onDragEnd={handleDragEnd}
measuring={{droppable: {strategy: MeasuringStrategy.Always}}}>
<SortableContext items={items as TAppList[]} strategy={rectSortingStrategy}>
{(items as TAppList[]).map((item): ReactElement => (
<SortableItem
key={item.id}
id={item.id}
item={item}
animateLayoutChanges={animateLayoutChanges}
onRemove={handleRemove}
/>
))}
</SortableContext>
</DndContext>
</div>
<div className={'mt-10'}>
<p
onClick={(): void => set_items(YEARN_APPS)}
className={'opacity-40 hover:opacity-100 transition-opacity cursor-pointer'}>
{'Reset dashboard'}
</p>
</div>
</div>
<Card>
<ColorPaletteLight />
</Card>
</section>
);
}

export default Index;
export default DashboardPage;
Loading

0 comments on commit 7ce2f78

Please sign in to comment.