Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
B
burger-project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Антон Тыщенко
burger-project
Commits
1f92f8df
Commit
1f92f8df
authored
Nov 27, 2025
by
anton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first_lesson-1
parent
442a9334
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
98 additions
and
51 deletions
+98
-51
App.tsx
src/App.tsx
+3
-31
Burger.tsx
src/components/Burger/Burger.tsx
+25
-3
Ingredient.tsx
src/components/Burger/Ingredient/Ingredient.tsx
+27
-7
BurgerBuilder.tsx
src/containers/BurgerBuilder/BurgerBuilder.tsx
+15
-2
burger-interface.ts
src/interfaces/burger-interface.ts
+5
-0
tsconfig.json
tsconfig.json
+14
-5
vite.config.ts
vite.config.ts
+9
-3
No files found.
src/App.tsx
View file @
1f92f8df
import
{
useState
}
from
'react'
import
{
BurgerBuilder
}
from
"@/containers/BurgerBuilder/BurgerBuilder"
;
import
reactLogo
from
'./assets/react.svg'
import
viteLogo
from
'/vite.svg'
import
'./App.css'
function
App
()
{
function
App
()
{
const
[
count
,
setCount
]
=
useState
(
0
)
return
<
BurgerBuilder
/>;
return
(
<>
<
div
>
<
a
href=
"https://vite.dev"
target=
"_blank"
>
<
img
src=
{
viteLogo
}
className=
"logo"
alt=
"Vite logo"
/>
</
a
>
<
a
href=
"https://react.dev"
target=
"_blank"
>
<
img
src=
{
reactLogo
}
className=
"logo react"
alt=
"React logo"
/>
</
a
>
</
div
>
<
h1
>
Vite + React
</
h1
>
<
div
className=
"card"
>
<
button
onClick=
{
()
=>
setCount
((
count
)
=>
count
+
1
)
}
>
count is
{
count
}
</
button
>
<
p
>
Edit
<
code
>
src/App.tsx
</
code
>
and save to test HMR
</
p
>
</
div
>
<
p
className=
"read-the-docs"
>
Click on the Vite and React logos to learn more
</
p
>
</>
)
}
}
export
default
App
export
default
App
;
src/components/Burger/Burger.tsx
View file @
1f92f8df
import
{
Ingredients
}
from
"@/interfaces/burger-interface"
;
import
"./Burger.css"
;
import
"./Burger.css"
;
import
{
Ingredient
}
from
"@/components/Burger/Ingredient/Ingredient"
;
import
{
ReactNode
}
from
"react"
;
interface
Props
{}
interface
Props
{
ingredients
:
Ingredients
;
}
export
function
Burger
({
ingredients
}:
Props
)
{
const
ingKeys
=
Object
.
keys
(
ingredients
)
as
(
keyof
Ingredients
)[];
let
ingList
:
ReactNode
[]
=
[];
ingKeys
.
forEach
((
key
)
=>
{
const
amount
=
ingredients
[
key
];
});
export
function
Burger
(
props
:
Props
)
{
return
(
return
null
;
<
div
className=
"Burger"
>
<
Ingredient
type=
{
"bread-top"
}
/>
<
Ingredient
type=
{
"cheese"
}
/>
<
Ingredient
type=
{
"bacon"
}
/>
<
Ingredient
type=
{
"meat"
}
/>
<
Ingredient
type=
{
"salad"
}
/>
<
Ingredient
type=
{
"bread-bottom"
}
/>
</
div
>
);
}
}
src/components/Burger/Ingredient/Ingredient.tsx
View file @
1f92f8df
import
{
IngredientNames
}
from
"@/interfaces/burger-interface"
;
import
"./Ingredient.css"
;
import
"./Ingredient.css"
;
interface
Props
{}
interface
Props
{
type
:
IngredientNames
;
}
export
function
Ingredient
({
type
}:
Props
)
{
switch
(
type
)
{
case
"bread-top"
:
return
(
<
div
className=
"BreadTop"
>
<
div
className=
"Seeds1"
></
div
>
<
div
className=
"Seeds2"
></
div
>
</
div
>
);
case
"bread-bottom"
:
return
<
div
className=
"BreadBottom"
></
div
>;
case
"bacon"
:
return
<
div
className=
"Bacon"
></
div
>;
export
type
IngredientNames
=
"salad"
|
"cheese"
|
"meat"
|
"bacon"
;
case
"cheese"
:
return
<
div
className=
"Cheese"
></
div
>;
export
type
Ingredients
=
{
case
"meat"
:
[
key
in
IngredientNames
]:
number
;
return
<
div
className=
"Meat"
></
div
>;
};
export
function
Ingredient
(
props
:
Props
)
{
case
"salad"
:
return
null
;
return
<
div
className=
"Salad"
></
div
>;
}
}
}
src/containers/BurgerBuilder/BurgerBuilder.tsx
View file @
1f92f8df
import
{
BuildControls
}
from
"@/components/BuildControls/BuildControls"
;
import
{
Burger
}
from
"@/components/Burger/Burger"
;
import
{
Ingredients
}
from
"@/interfaces/burger-interface"
;
import
{
useState
}
from
"react"
;
export
function
BurgerBuilder
()
{
export
function
BurgerBuilder
()
{
const
[
ingredients
,
setIngredients
]
=
useState
<
Ingredients
>
({
salad
:
0
,
cheese
:
0
,
bacon
:
0
,
meat
:
0
,
"bread-bottom"
:
0
,
"bread-top"
:
0
,
});
return
(
return
(
<>
<>
<
div
>
Burger will be here
</
div
>
<
Burger
ingredients=
{
ingredients
}
/
>
<
div
>
Build controls will be here
</
div
>
<
BuildControls
/
>
</>
</>
);
);
}
}
src/interfaces/burger-interface.ts
0 → 100644
View file @
1f92f8df
export
type
IngredientNames
=
"salad"
|
"cheese"
|
"meat"
|
"bacon"
|
"bread-top"
|
"bread-bottom"
;
export
type
Ingredients
=
{
[
key
in
IngredientNames
]:
number
;
};
tsconfig.json
View file @
1f92f8df
{
{
"files"
:
[],
"compilerOptions"
:
{
"references"
:
[
"target"
:
"ESNext"
,
{
"path"
:
"./tsconfig.app.json"
},
"useDefineForClassFields"
:
true
,
{
"path"
:
"./tsconfig.node.json"
}
"module"
:
"ESNext"
,
]
"moduleResolution"
:
"Node"
,
"strict"
:
true
,
"jsx"
:
"react-jsx"
,
"baseUrl"
:
"."
,
"paths"
:
{
"@/*"
:
[
"src/*"
]
}
},
"include"
:
[
"src"
]
}
}
vite.config.ts
View file @
1f92f8df
import
{
defineConfig
}
from
'vite'
import
{
defineConfig
}
from
"vite"
;
import
react
from
'@vitejs/plugin-react'
import
react
from
"@vitejs/plugin-react"
;
import
path
from
"path"
;
// https://vite.dev/config/
// https://vite.dev/config/
export
default
defineConfig
({
export
default
defineConfig
({
plugins
:
[
react
()],
plugins
:
[
react
()],
})
resolve
:
{
alias
:
{
"@"
:
path
.
resolve
(
__dirname
,
"./src"
),
},
},
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment