Skip to content

Commit 814550f

Browse files
refactor: refactor sections (#40)
1 parent d607827 commit 814550f

25 files changed

+302
-526
lines changed

src/pages/home/Home.styled.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,6 @@ export const NarrowColumn = styled.div(
5858
`
5959
);
6060

61-
export const BaseLayoutElement = styled.div(
62-
({ theme: { custom } }) => css`
63-
border: 1px solid ${custom.sys.colors.border};
64-
background: ${custom.sys.colors.container};
65-
transition:
66-
background-color ${custom.sys.transitions.color},
67-
border-color ${custom.sys.transitions.color};
68-
margin: 0;
69-
padding: 10px;
70-
border-radius: 8px;
71-
`
72-
);
73-
74-
export const List = styled(BaseLayoutElement)`
75-
display: flex;
76-
flex-direction: column;
77-
padding: 10px;
78-
gap: 20px;
79-
overflow: auto;
80-
position: relative;
81-
`;
82-
8361
export const sharedComponentStyles = ({ theme }: { theme: Theme }) => css`
8462
min-height: 10vh;
8563
@media (min-width: ${theme.custom.sys.breakpoints.desktop}px) {

src/pages/home/sections/Callstack/Callstack.modal.tsx

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,14 @@
11
import styled from '@emotion/styled';
22
import { css } from '@emotion/react';
3-
import { TransparentButton } from 'components/TransparentButton/TransparentButton.tsx';
3+
import { BaseQueue } from 'pages/home/sections/base/BaseQueue/BaseQueue.tsx';
44

5-
export const Callstack = styled.div(
5+
export const Callstack = styled(BaseQueue)(
66
({ theme }) => css`
7-
flex: 1;
8-
display: flex;
97
flex-direction: row-reverse;
108
justify-content: end;
11-
gap: 20px;
129
1310
@media (min-width: ${theme.custom.sys.breakpoints.desktop}px) {
1411
flex-direction: column-reverse;
1512
}
1613
`
1714
);
18-
19-
export const CallstackElement = styled.div(
20-
({ theme: { custom } }) => css`
21-
background: ${custom.com.queueElement.background};
22-
transition: background-color ${custom.sys.transitions.color};
23-
animation: ${custom.sys.animations.zoomIn};
24-
border: 1px solid ${custom.sys.colors.border};
25-
border-radius: 4px;
26-
padding: 10px;
27-
word-wrap: break-word;
28-
word-break: break-word;
29-
display: flex;
30-
align-items: center;
31-
justify-content: center;
32-
flex: 1;
33-
max-width: 33.33%;
34-
35-
@media (min-width: ${custom.sys.breakpoints.desktop}px) {
36-
max-width: unset;
37-
flex-grow: 0;
38-
}
39-
`
40-
);
41-
42-
export const InfoButton = styled(TransparentButton)`
43-
position: absolute;
44-
top: 8px;
45-
right: 8px;
46-
`;
47-
48-
export const CloseButton = styled(TransparentButton)`
49-
position: absolute;
50-
top: 12px;
51-
right: 12px;
52-
`;

src/pages/home/sections/Callstack/Callstack.tsx

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,54 @@
11
import * as Styled from './Callstack.styled.ts';
2-
import useBoolean from 'utils/hooks/useBoolean.ts';
3-
import { List } from '../../Home.styled.ts';
4-
import CallStackModal from './Callstack.modal.tsx';
52
import { useQueueManagerStore } from 'store/store.ts';
6-
import { Icon } from 'components/Icon/Icon.tsx';
7-
import { useTheme } from '@emotion/react';
3+
import { BaseModalSection } from 'pages/home/sections/base/BaseModalSection/BaseModalSection.tsx';
4+
import { BaseQueueElement } from 'pages/home/sections/base/BaseQueueElement/BaseQueueElement.tsx';
5+
6+
const ModalContent = (
7+
<>
8+
<h2>Call stack</h2>
9+
<p>
10+
A call stack is a mechanism for an interpreter to keep track of its place
11+
in a script that calls multiple functions — what function is currently
12+
being run and what functions are called from within that function, etc.
13+
</p>
14+
<ul>
15+
<li>
16+
When a script calls a function, the interpreter adds it to the call
17+
stack and then starts carrying out the function.
18+
</li>
19+
<li>
20+
Any functions that are called by that function are added to the call
21+
stack further up, and run where their calls are reached.
22+
</li>
23+
<li>
24+
When the current function is finished, the interpreter takes it off the
25+
stack and resumes execution where it left off in the last code listing.
26+
</li>
27+
<li>
28+
If the stack takes up more space than it was assigned, a "stack
29+
overflow" error is thrown.
30+
</li>
31+
</ul>
32+
</>
33+
);
834

935
function CallStack({ className }: { className?: string }) {
1036
const tasks = useQueueManagerStore((state) => state.callstack);
11-
const [isOpened, toggle] = useBoolean(false);
12-
const theme = useTheme();
1337

1438
return (
15-
<List className={className}>
16-
<span>CallStack</span>
39+
<BaseModalSection
40+
className={className}
41+
title={'CallStack'}
42+
modalContent={ModalContent}
43+
>
1744
<Styled.Callstack>
18-
<Styled.InfoButton onClick={toggle}>
19-
<Icon variant={'info'} color={theme.custom.com.icon.background} />
20-
</Styled.InfoButton>
2145
{tasks.map((task) => (
22-
<Styled.CallstackElement key={task}>{task}</Styled.CallstackElement>
46+
<BaseQueueElement isVertical key={task}>
47+
{task}
48+
</BaseQueueElement>
2349
))}
24-
<CallStackModal isOpened={isOpened} toggle={toggle} />
2550
</Styled.Callstack>
26-
</List>
51+
</BaseModalSection>
2752
);
2853
}
2954

src/pages/home/sections/Configurator/Configurator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as Styled from './Configurator.styled.ts';
2-
import { BaseLayoutElement } from '../../Home.styled.ts';
32
import Controls from './Controls/Controls.tsx';
43
import Editor from './Editor/Editor.tsx';
54
import { codeExamples } from './Configurator.data.tsx';
65
import { useState } from 'react';
6+
import { BaseLayoutElement } from 'pages/home/sections/base/BaseLayoutElement/BaseLayoutElement.tsx';
77

88
export default function Configurator({ className }: { className?: string }) {
99
const [text, setText] = useState(codeExamples[3].code);
Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,11 @@
11
import styled from '@emotion/styled';
22
import { css } from '@emotion/react';
3+
import { BaseQueue } from 'pages/home/sections/base/BaseQueue/BaseQueue.tsx';
34

4-
export const LogQueue = styled.div(
5+
export const LogQueue = styled(BaseQueue)(
56
({ theme }) => css`
6-
flex: 1;
7-
display: flex;
8-
justify-content: start;
9-
gap: 20px;
10-
117
@media (min-width: ${theme.custom.sys.breakpoints.desktop}px) {
128
flex-direction: column;
139
}
1410
`
1511
);
16-
17-
export const Log = styled.div(
18-
({
19-
theme: {
20-
custom: { sys, com },
21-
},
22-
}) => css`
23-
background: ${com.queueElement.background};
24-
transition: background-color ${sys.transitions.color};
25-
animation: ${sys.animations.zoomIn};
26-
border: 1px solid ${sys.colors.border};
27-
border-radius: 4px;
28-
padding: 10px;
29-
word-wrap: break-word;
30-
display: flex;
31-
align-items: center;
32-
justify-content: center;
33-
flex: 1;
34-
max-width: 33.33%;
35-
36-
@media (min-width: ${sys.breakpoints.desktop}px) {
37-
max-width: unset;
38-
flex-grow: 0;
39-
}
40-
`
41-
);

src/pages/home/sections/Console/Console.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { useQueueManagerStore } from 'store/store.ts';
22
import * as Styled from './Console.styled.ts';
3-
import { List } from '../../Home.styled.ts';
3+
import { BaseSection } from 'pages/home/sections/base/BaseSection/BaseSection.tsx';
4+
import { BaseQueueElement } from 'pages/home/sections/base/BaseQueueElement/BaseQueueElement.tsx';
45

56
function Console({ className }: { className?: string }) {
67
const tasks = useQueueManagerStore((state) => state.console);
78

89
return (
9-
<List className={className}>
10-
<span>Console</span>
10+
<BaseSection className={className} title={'Console'}>
1111
<Styled.LogQueue>
1212
{tasks.map((log, i) => (
13-
<Styled.Log key={log + i}>{log}</Styled.Log>
13+
<BaseQueueElement isVertical key={log + i}>
14+
{log}
15+
</BaseQueueElement>
1416
))}
1517
</Styled.LogQueue>
16-
</List>
18+
</BaseSection>
1719
);
1820
}
1921

src/pages/home/sections/EventLoop/EventLoop.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as Styled from './EventLoop.styled.ts';
22
import useBoolean from 'utils/hooks/useBoolean.ts';
3-
import { BaseLayoutElement } from 'pages/home/Home.styled.ts';
43
import { EVENT_LOOP_ID } from 'utils/constants.ts';
54
import EventLoopModal from './EventLoop.modal.tsx';
65
import Wheel from 'pages/home/sections/EventLoop/Wheel/Wheel.tsx';
76
import { Icon } from 'components/Icon/Icon.tsx';
87
import { useTheme } from '@emotion/react';
8+
import { BaseLayoutElement } from 'pages/home/sections/base/BaseLayoutElement/BaseLayoutElement.tsx';
99

1010
function EventLoop({ className }: { className?: string }) {
1111
const [isOpened, toggle] = useBoolean(false);

src/pages/home/sections/MicroTasksQueue/MicroTasksQueue.modal.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/pages/home/sections/MicroTasksQueue/MicroTasksQueue.styled.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)