Skip to content

Commit

Permalink
feat(website): add colorPage
Browse files Browse the repository at this point in the history
  • Loading branch information
iljs committed Jul 9, 2024
1 parent d7988ca commit 7cf7d86
Show file tree
Hide file tree
Showing 14 changed files with 314 additions and 297 deletions.
165 changes: 0 additions & 165 deletions website/plasma-website/components/colors/Pallete.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import styled from 'styled-components';

const GradientScrollContainer = styled.div`
const fixPadding = 212;

const GradientScrollContainer = styled.div<{ padding: number }>`
position: fixed;
top: 7.5rem;
height: calc(100vh - 208px);
height: calc(100vh - ${({ padding }) => padding}px);
left: 0;
width: 4rem;
padding-left: 1.875rem;
Expand Down Expand Up @@ -64,16 +66,39 @@ const GradientScrollBottomText = styled.div`
export const GradientScroll: React.FC<{
hsl: number[];
colors: string[];
scrollHeight: number;
scrollTop: number;
height: number;
}> = ({ hsl, colors, scrollHeight, scrollTop, height }) => {
const heightAllScroll = height - 212;
const heightScroll = heightAllScroll / (scrollHeight / height);
const topScroll = heightAllScroll * (scrollTop / scrollHeight) + 2;
scrollRef: React.RefObject<HTMLDivElement>;
}> = ({ hsl, colors, scrollRef }) => {
const [scrollPosition, setScrollPosition] = useState(0);

const scrollHeight = scrollRef?.current?.scrollHeight ?? 0;
const clientHeight = scrollRef?.current?.scrollHeight ?? 0;

const heightAllScroll = clientHeight - fixPadding;
const heightScroll = heightAllScroll / (scrollHeight / clientHeight);
const topScroll = heightAllScroll * (scrollPosition / scrollHeight) + 2;

const handlerScroll = () => {
if (scrollRef.current) {
const { scrollTop } = scrollRef.current;
setScrollPosition(scrollTop);
}
};

useEffect(() => {
if (scrollRef?.current) {
scrollRef.current.addEventListener('scroll', handlerScroll);
handlerScroll();

return () => {
if (scrollRef.current) {
scrollRef.current.removeEventListener('scroll', handlerScroll);
}
};
}
}, []);

return (
<GradientScrollContainer>
<GradientScrollContainer padding={fixPadding}>
<GradientScrollContainerScroll>
<GradientScrollTopText>H:{hsl[0]}</GradientScrollTopText>
<GradientScrollHeight colors={colors} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import styled from 'styled-components';

const HeaderWrapper = styled.div`
const HeaderWrapper = styled.a`
display: flex;
top: 2rem;
left: 1.625rem;
Expand All @@ -10,6 +10,8 @@ const HeaderWrapper = styled.div`
align-items: center;
cursor: pointer;
z-index: 99999;
color: rgba(255, 255, 255, 1);
text-decoration: none;
&:hover .hoverHeader {
opacity: 1;
Expand All @@ -26,9 +28,9 @@ const HeaderTextBold = styled(HeaderText)`
opacity: 1;
`;

export const Header: React.FC<{ text?: string; onClose?: () => void }> = ({ text, onClose }) => {
export const Header: React.FC<{ text?: string; link?: string }> = ({ text, link }) => {
return (
<HeaderWrapper onClick={() => onClose?.()}>
<HeaderWrapper href={link}>
<HeaderText className="hoverHeader"></HeaderText>
<HeaderTextBold>{text}</HeaderTextBold>
</HeaderWrapper>
Expand Down
Loading

0 comments on commit 7cf7d86

Please sign in to comment.