Skip to content
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
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Home from './pages/home/Home.tsx';
import { StylesProvider } from './styles/styles.provider.tsx';
import { StylesProvider } from 'providers/StylesProvider.tsx';

function App() {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/CloseIcon/InfoIcon.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { css } from '@emotion/react';
export const Closed = styled.svg(
({ theme }) => css`
cursor: pointer;
fill: ${theme.custom.colors.onContainerNormal};
fill: ${theme.custom.colors.onContainer.normal};

&:hover {
fill: ${theme.custom.colors.text};
fill: ${theme.custom.colors.onContainer.contrast};
}
`
);
4 changes: 2 additions & 2 deletions src/components/InfoIcon/InfoIcon.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export const Info = styled.svg(
top: 4px;
right: 4px;
cursor: pointer;
fill: ${theme.custom.colors.onContainerNormal};
fill: ${theme.custom.colors.onContainer.normal};

&:hover {
fill: ${theme.custom.colors.text};
fill: ${theme.custom.colors.onContainer.contrast};
}
`
);
2 changes: 1 addition & 1 deletion src/components/MoonIcon/MoonIcon.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { css } from '@emotion/react';
export const Sun = styled.svg(
({ theme }) => css`
cursor: pointer;
fill: ${theme.custom.colors.text};
fill: ${theme.custom.colors.onContainer.contrast};
`
);
2 changes: 1 addition & 1 deletion src/components/MoonIcon/MoonIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function MoonIcon({
onClick: () => void;
}) {
const theme = useTheme();
const textColor = theme.custom.colors.text;
const textColor = theme.custom.colors.onContainer.contrast;

return (
<Styled.Sun
Expand Down
2 changes: 1 addition & 1 deletion src/components/SunIcon/SunIcon.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { css } from '@emotion/react';
export const Sun = styled.svg(
({ theme }) => css`
cursor: pointer;
fill: ${theme.custom.colors.text};
fill: ${theme.custom.colors.onContainer.contrast};
`
);
2 changes: 1 addition & 1 deletion src/components/SunIcon/SunIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function SunIcon({
onClick: () => void;
}) {
const theme = useTheme();
const textColor = theme.custom.colors.text;
const textColor = theme.custom.colors.onContainer.contrast;

return (
<Styled.Sun
Expand Down
27 changes: 9 additions & 18 deletions src/emotion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import '@emotion/react';
declare module '@emotion/react' {
export interface Theme {
custom: {
mode: 'light' | 'dark';
breakpoints: {
desktop: number;
};
Expand All @@ -14,26 +15,16 @@ declare module '@emotion/react' {
};
colors: {
background: string;
onBackground: string;
container: string;
onContainerNormal: string;
onContainerContrast: string;
text: string;

wheel: {
background: string;
microtask: {
disabled: string;
enabled: string;
};
macrotask: {
disabled: string;
enabled: string;
};
render: {
disabled: string;
enabled: string;
};
onContainer: {
dim: string;
normal: string;
contrast: string;
};
primary: string;
secondary: string;
tertiary: string;
};
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/Home.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const NarrowColumn = styled.div(

export const BaseLayoutElement = styled.div(
({ theme }) => css`
border: 1px solid ${theme.custom.colors.wheel.background};
border: 1px solid ${theme.custom.colors.onContainer.dim};
background: ${theme.custom.colors.container};
margin: 0;
padding: 10px;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/sections/Callstack/Callstack.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const Callstack = styled.div`

export const CallstackElement = styled.div(
({ theme }) => css`
background: ${theme.custom.colors.onContainerNormal};
background: ${theme.custom.colors.onContainer.dim};
border-radius: 5px;
padding: 10px;
word-wrap: break-word;
Expand Down
7 changes: 4 additions & 3 deletions src/pages/home/sections/Configurator/Editor/Editor.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ export const EditorWrapper = styled.div(
}

.ace_gutter {
background: ${theme.custom.colors.wheel.background};
background: ${theme.custom.colors.onContainer.dim};
}

.selected_lines {
position: absolute;
background: ${theme.custom.colors.wheel.macrotask.disabled};
background: ${theme.custom.colors.tertiary};
opacity: 0.3;
}

.ace_gutter-active-line {
background: ${theme.custom.colors.wheel.background};
background: ${theme.custom.colors.onContainer.dim};
}

.ace_content {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/sections/Console/Console.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const LogQueue = styled.div`

export const Log = styled.div(
({ theme }) => css`
background: ${theme.custom.colors.onContainerNormal};
background: ${theme.custom.colors.onContainer.dim};
border-radius: 5px;
padding: 10px;
word-wrap: break-word;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const MicroTasksQueue = styled.div`

export const MicroTask = styled.div(
({ theme }) => css`
background: ${theme.custom.colors.onContainerNormal};
background: ${theme.custom.colors.onContainer.dim};
flex: 1;
display: flex;
justify-content: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const CallbacksQueue = styled.div`

export const Callback = styled.div(
({ theme }) => css`
background: ${theme.custom.colors.onContainerNormal};
background: ${theme.custom.colors.onContainer.dim};
flex: 1;
display: flex;
justify-content: center;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/sections/TasksQueue/TasksQueue.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const TasksQueue = styled.div`

export const Task = styled.div(
({ theme }) => css`
background: ${theme.custom.colors.onContainerNormal};
background: ${theme.custom.colors.onContainer.dim};
flex: 1;
display: flex;
justify-content: center;
Expand Down
6 changes: 3 additions & 3 deletions src/pages/home/sections/WebApiQueue/WebApiTask.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { css } from '@emotion/react';

export const WebApiItem = styled.div(
({ theme }) => css`
background: ${theme.custom.colors.onContainerNormal};
background: ${theme.custom.colors.onContainer.dim};
border-radius: 5px;
padding: 10px;
position: absolute;
Expand All @@ -22,8 +22,8 @@ export const Progress = styled.div<{ progress: number }>(
({ theme, progress }) => css`
background-color: transparent;
background-image: conic-gradient(
${theme.custom.colors.onContainerContrast},
${theme.custom.colors.onContainerContrast} ${progress}%,
${theme.custom.colors.onContainer.contrast},
${theme.custom.colors.onContainer.contrast} ${progress}%,
transparent ${progress}%
);
border-radius: 5px;
Expand Down
16 changes: 11 additions & 5 deletions src/pages/home/sections/Wheel/Pointer/Pointer.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const SectorWithInnerBorder = styled.div(
border-image: linear-gradient(
to right,
transparent 50%,
${colors.text} 50%
${colors.onContainer.contrast} 50%
);
box-sizing: border-box;

Expand All @@ -46,7 +46,8 @@ export const SectorWithInnerBorder = styled.div(
0 0;
transform-origin: 50% 100%;
transform: rotate(160deg);
border-left: ${eventLoopPointerBorderWidth}px solid ${colors.text};
border-left: ${eventLoopPointerBorderWidth}px solid
${colors.onContainer.contrast};
box-sizing: border-box;
left: 0;
}
Expand All @@ -66,7 +67,11 @@ export const SectorWithOuterBorder = styled.div(
transform-origin: 50% 100%;
transform: rotate(280deg);
border-bottom: ${widths.eventLoopPointerBorderWidth}px solid transparent;
border-image: linear-gradient(to right, transparent 50%, ${colors.text} 50%)
border-image: linear-gradient(
to right,
transparent 50%,
${colors.onContainer.contrast} 50%
)
1;
box-sizing: border-box;

Expand All @@ -77,10 +82,11 @@ export const SectorWithOuterBorder = styled.div(
content: '';
border-radius: ${widths.eventLoopRadius}px ${widths.eventLoopRadius}px 0 0;
border-bottom: ${widths.eventLoopPointerBorderWidth}px solid
${colors.text};
${colors.onContainer.contrast};
transform-origin: 50% 100%;
transform: rotate(160deg);
border-left: ${widths.eventLoopPointerBorderWidth}px solid ${colors.text};
border-left: ${widths.eventLoopPointerBorderWidth}px solid
${colors.onContainer.contrast};
box-sizing: border-box;
left: 0;
}
Expand Down
31 changes: 26 additions & 5 deletions src/pages/home/sections/Wheel/Wheel.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,31 @@ export const CircleOuter = styled.div(
left: 0;
right: 0;
bottom: 0;
background: ${theme.custom.colors.wheel.background};
background: ${theme.custom.colors.onContainer.dim};
border-radius: 50%;
`
);

export const Sector = styled.div<{ background: string; degree: number }>(
({ theme, background, degree }) => css`
export const Sector = styled.div<{
background: string;
degree: number;
enabled: boolean;
}>(({ theme, background, degree, enabled }) => {
const saturation = {
light: 2,
dark: 1.3,
}[theme.custom.mode];
const brightness = {
light: {
enabled: 1.4,
disabled: 1,
},
dark: {
enabled: 1,
disabled: 0.8,
},
}[theme.custom.mode];
return css`
height: ${theme.custom.widths.eventLoopRadius}px;
width: ${theme.custom.widths.eventLoopDiameter}px;
overflow: hidden;
Expand All @@ -52,12 +70,15 @@ export const Sector = styled.div<{ background: string; degree: number }>(
border-radius: ${theme.custom.widths.eventLoopRadius}px
${theme.custom.widths.eventLoopRadius}px 0 0;
background-color: ${background};
filter: saturate(${saturation})
brightness(${enabled ? brightness.enabled : brightness.disabled});
opacity: ${enabled ? 1 : 0.3};
transform-origin: 50% 100%;
transform: rotate(160deg);
left: 0;
}
`
);
`;
});

export const CloseIcon = styled(InfoClosed)`
position: absolute;
Expand Down
12 changes: 10 additions & 2 deletions src/pages/home/sections/Wheel/Wheel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ function Wheel({ className }: { className?: string }) {
const theme = useTheme();
const [isOpened, toggle] = useBoolean(false);

const { primary, secondary, tertiary } = theme.custom.colors;
const colors = {
microtask: primary,
macrotask: secondary,
render: tertiary,
};

return (
<BaseLayoutElement className={className}>
<p id={EVENT_LOOP_ID}>Event Loop</p>
Expand All @@ -26,12 +33,13 @@ function Wheel({ className }: { className?: string }) {
<Styled.CircleContainer>
<Styled.CircleOuter />
{events.map(({ degree, type }) => {
const enabled = stops[type] ? 'enabled' : 'disabled';
const background = theme.custom.colors.wheel[type][enabled];
const enabled = stops[type];
const background = colors[type];
return (
<Styled.Sector
id={`sector-${type}-new`}
key={degree}
enabled={enabled}
background={background}
degree={360 - degree + 10}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Global, ThemeProvider } from '@emotion/react';
import { PropsWithChildren } from 'react';
import { useThemeStore } from 'store/store.ts';
import { darkTheme, lightTheme } from './styles.theme.ts';
import { getGlobalStyles } from './styles.utils.ts';
import { getGlobalStyles } from './StylesProvider.utils.ts';
import { colorsDark, colorsLight } from '../theme/colors.ts';
import { getTheme } from '../theme/theme.ts';

export function StylesProvider({ children }: PropsWithChildren) {
const { isDark } = useThemeStore();
const theme = isDark ? darkTheme : lightTheme;
const palette = isDark ? colorsDark : colorsLight;
const theme = getTheme(palette);
const globalStyles = getGlobalStyles({ theme });

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { css, Theme } from '@emotion/react';
export const getGlobalStyles = ({ theme }: { theme: Theme }) => css`
html {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
color: ${theme.custom.colors.text};
color: ${theme.custom.colors.onBackground};
background-color: ${theme.custom.colors.background};
height: 100%;
}
Expand All @@ -25,7 +25,7 @@ export const getGlobalStyles = ({ theme }: { theme: Theme }) => css`
}

a {
color: ${theme.custom.colors.text};
color: ${theme.custom.colors.onBackground};
}

body {
Expand Down Expand Up @@ -56,10 +56,10 @@ export const getGlobalStyles = ({ theme }: { theme: Theme }) => css`
}

::-webkit-scrollbar-thumb {
background: ${theme.custom.colors.onContainerNormal};
background: ${theme.custom.colors.onContainer.normal};
}

:focus-visible {
outline: 2px solid ${theme.custom.colors.onContainerNormal};
outline: 2px solid ${theme.custom.colors.onContainer.normal};
}
`;
Loading
Loading