spacedrive/interface/components/TrafficLights.tsx
Jamie Pine 77a6ab1d73
Release landing page (#1464)
* start

* not for this branch lol

* fix dates

* fix spacing

* revert mistake

* progress

* blog

* improve wording

* more blog

* more blog moment

* moreee blog

* cant spell can i

* bloggggg

* change name

* some rambling

* sentence meowment

* merge

* prep

* perfect app ui template for landing

* updated landing image

* fix border

* section

* fix query param handling

* remove apps/snapshot

* remove `WindowControls`

* Playwright in setup script

* `showControls` in a store

* better screenshot + fixed stars with fadeout

* fix show controls store mistake

* begin bento boxes

* bento box stuff

* taggrid

* release blog post: clarifying punctuation & rearrange some sentences (#1097)

* landing page wip

* Update index.tsx

* tweak

* Update pnpm-lock.yaml

* Update app.webp

* better app image + line animation wip

* wip

* tweak + image

* tweaks + 60 fps ball

* 60 fps platforms anim

* landing updates

* static globe

* tweaks

* device detect and dynamic imports

* Accessibility and minor performance improvements from Lh report.

* Update globe.webp

* Improve randomness of line animation, better cloud image

* isMobile vid support

* Update index.tsx

* new art

* docs

* docs

* Improvements and feedback

* Update index.tsx

* improvements

* quick art tweak

* updated art

* increase size

* SVG animation

* animations

* convert platforms to arr and framer motion

* new section - wip preview

* remove border app animation - more animation work

* mobile tweaks

* tweak

* duration adjustment

* animation improvements

* different floating times for other circles

* Pricing page

* tweak

* optimize images, accessibility values, svg attribute cleanup

* launch prep

* fix blog link

* adding location docs

* hover effect

* fixes to layout

* Update index.tsx

* another show controls method

* use PageLayoutContext in other file

* merge

* desktop release download api

* update publishing api

* hook up desktop releases api to landing page

* screenshot stuff

* Delete .github/scripts/setup-system.sh

* Update october-alpha-release.mdx

* rotating screenshots, fixed blog and apple download chooser

---------

Co-authored-by: Utku Bakir <74243531+utkubakir@users.noreply.github.com>
Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me>
Co-authored-by: pr <pineapplerind.info@gmail.com>
Co-authored-by: ameer2468 <33054370+ameer2468@users.noreply.github.com>
Co-authored-by: Brendan Allan <brendonovich@outlook.com>
2023-10-11 04:05:40 +00:00

79 lines
2.5 KiB
TypeScript

import closeIconPath from '@sd/assets/svgs/macos_close.svg';
import fullscreenIconPath from '@sd/assets/svgs/macos_fullscreen.svg';
import minimizeIconPath from '@sd/assets/svgs/macos_minimize.svg';
import clsx from 'clsx';
import { ComponentProps, HTMLAttributes, useEffect, useRef } from 'react';
import { useFocusState } from '~/hooks/useFocusState';
export interface TrafficLightsProps extends ComponentProps<'div'> {
onClose?: () => void;
onMinimize?: () => void;
onFullscreen?: () => void;
}
export function MacTrafficLights(props: TrafficLightsProps) {
const { onClose, onMinimize, onFullscreen, className } = props;
const [focused] = useFocusState();
return (
<div
data-tauri-drag-region
className={clsx('group flex flex-row space-x-[7.5px]', className)}
>
<TrafficLight type="close" onClick={onClose} colorful={focused ?? false} />
<TrafficLight type="minimize" onClick={onMinimize} colorful={focused ?? false} />
<TrafficLight type="fullscreen" onClick={onFullscreen} colorful={focused ?? false} />
</div>
);
}
interface TrafficLightProps {
type: 'close' | 'minimize' | 'fullscreen';
colorful: boolean;
onClick?: HTMLAttributes<HTMLDivElement>['onClick'];
}
function TrafficLight(props: TrafficLightProps) {
const { onClick = () => undefined, colorful = false, type } = props;
const iconPath = useRef<string>(closeIconPath);
useEffect(() => {
switch (type) {
case 'close':
iconPath.current = closeIconPath;
break;
case 'minimize':
iconPath.current = minimizeIconPath;
break;
case 'fullscreen':
iconPath.current = fullscreenIconPath;
break;
}
}, [type]);
return (
<div
onClick={onClick}
className={clsx(
'box-content flex h-[12px] w-[12px] items-center justify-center rounded-full border-[0.5px] border-transparent bg-[#CDCED0] dark:bg-[#2B2C2F]',
{
'border-red-900 !bg-[#EC6A5E] active:hover:!bg-red-700 dark:active:hover:!bg-red-300':
type === 'close' && colorful,
'group-hover:!bg-[#EC6A5E] ': type === 'close',
'border-[#F4BE4F] !bg-[#F4BE4F] active:hover:!bg-yellow-600 dark:active:hover:!bg-yellow-200':
type === 'minimize' && colorful,
'group-hover:!bg-[#F4BE4F]': type === 'minimize',
'border-green-900 !bg-[#61C253] active:hover:!bg-green-700 dark:active:hover:!bg-green-300':
type === 'fullscreen' && colorful,
' group-hover:!bg-[#61C253] ': type === 'fullscreen'
}
)}
>
<img
src={iconPath.current}
className="pointer-events-none opacity-0 group-hover:opacity-100 group-active:opacity-100"
/>
</div>
);
}