Skip to content

Commit 99e06aa

Browse files
author
Dany Boza
committed
add text panel #37
1 parent 9d34543 commit 99e06aa

File tree

7 files changed

+105
-5
lines changed

7 files changed

+105
-5
lines changed

.env

-2
This file was deleted.

.env.sample

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
REACT_APP_ICONSCOUT_CLIENT_ID="client-id"
2+
REACT_APP_ICONSCOUT_SECRET="client-secret"

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
24+
25+
.env

public/index.html

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
<link rel="preconnect" href="https://fonts.gstatic.com" />
1111
<link href="https://fonts.googleapis.com/css2?family=Karla:wght@200;300&display=swap" rel="stylesheet" />
1212
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet" />
13+
<link rel="preconnect" href="https://fonts.gstatic.com" />
14+
<link
15+
href="https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;600;700&display=swap"
16+
rel="stylesheet"
17+
/>
1318
<!--
1419
manifest.json provides metadata used when your web app is installed on a
1520
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/

src/scenes/Editor/Panels/PanelItem/PanelItem.scss

+42
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,45 @@
3434
background: rgba($color: #fff, $alpha: 0.1);
3535
}
3636
}
37+
38+
// Panel Text
39+
.panel-text {
40+
width: 360px;
41+
color: #fff;
42+
.add-text-items {
43+
display: grid;
44+
gap: 0.5rem;
45+
}
46+
.label {
47+
font-weight: 600;
48+
padding: 0.8rem 0;
49+
font-size: 0.84rem;
50+
}
51+
.add-text-item {
52+
background: rgba($color: #fff, $alpha: 0.1);
53+
height: 50px;
54+
display: flex;
55+
align-items: center;
56+
padding-left: 1rem;
57+
cursor: pointer;
58+
transition: background 0.4s;
59+
&:hover {
60+
background: rgba($color: #fff, $alpha: 0.15);
61+
}
62+
}
63+
.add-heading {
64+
font-weight: 700;
65+
font-size: 1.66rem;
66+
}
67+
.add-subheading {
68+
background: rgba($color: #fff, $alpha: 0.1);
69+
font-size: 1.12rem;
70+
font-weight: 500;
71+
}
72+
.add-body-text {
73+
background: rgba($color: #fff, $alpha: 0.1);
74+
font-size: 0.76rem;
75+
font-weight: 400;
76+
color: rgba($color: #fff, $alpha: 0.9);
77+
}
78+
}

src/scenes/Editor/Panels/PanelItem/TextPanel.tsx

+53-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,65 @@
11
import { Input, InputGroup, InputLeftElement } from '@chakra-ui/react'
22
import { SearchIcon } from '@chakra-ui/icons'
3+
import { useCanvasContext } from '@/components/Canvas/hooks'
4+
import { fabric } from 'fabric'
35

46
function TextPanel() {
7+
const { canvas } = useCanvasContext()
8+
9+
const addHeading = () => {
10+
const text = new fabric.Textbox('Add a heading', {
11+
fontSize: 32,
12+
width: 320,
13+
fontWeight: 700,
14+
fontFamily: 'Lexend',
15+
textAlign: 'center',
16+
})
17+
canvas.add(text)
18+
text.center()
19+
}
20+
21+
const addSubheading = () => {
22+
const text = new fabric.Textbox('Add a subheading', {
23+
fontSize: 24,
24+
width: 320,
25+
fontWeight: 500,
26+
fontFamily: 'Lexend',
27+
textAlign: 'center',
28+
})
29+
canvas.add(text)
30+
text.center()
31+
}
32+
33+
const addTextBody = () => {
34+
const text = new fabric.Textbox('Add a little bit of body text', {
35+
fontSize: 18,
36+
width: 320,
37+
fontWeight: 300,
38+
fontFamily: 'Lexend',
39+
textAlign: 'center',
40+
})
41+
canvas.add(text)
42+
text.center()
43+
}
544
return (
645
<>
7-
<div style={{ padding: '1rem 2rem' }}>
46+
<div className="panel-text" style={{ padding: '1rem 1.5rem' }}>
847
<InputGroup>
9-
<InputLeftElement pointerEvents="none" children={<SearchIcon color="gray.300" />} />
48+
<InputLeftElement pointerEvents="none" children={<SearchIcon color="gray.600" />} />
1049
<Input style={{ background: '#fff' }} type="tel" placeholder="Search text" />
1150
</InputGroup>
51+
<div className="label">Click text to add to page</div>
52+
<div className="add-text-items">
53+
<div onClick={addHeading} className="add-text-item add-heading">
54+
Add a heading
55+
</div>
56+
<div onClick={addSubheading} className="add-text-item add-subheading">
57+
Add a subheading
58+
</div>
59+
<div onClick={addTextBody} className="add-text-item add-body-text">
60+
Add a litle bit of body text
61+
</div>
62+
</div>
1263
</div>
1364
</>
1465
)

src/scenes/Editor/Panels/Panels.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
box-shadow: 5px 0 5px -5px rgba(0, 0, 0, 0.5);
77
display: flex;
88
user-select: none;
9-
font-family: 'Karla';
9+
font-family: 'Lexend';
1010
}
1111

1212
.panel-item-close {

0 commit comments

Comments
 (0)