Skip to content

Commit 8737e59

Browse files
committed
feat: melhora alinhamento na sidenav e adiciona mais fundos 3D
1 parent 49b052c commit 8737e59

29 files changed

+279
-32
lines changed

public/images/delphi-3d.png

597 KB
Loading

public/images/front-in-maringa-3d.png

-196 KB
Loading

public/images/nodejs-3d.png

-233 KB
Loading

public/images/php-3d.png

-234 KB
Loading

public/images/rust-3d.png

-236 KB
Loading

public/images/silicio.svg

+122
Loading

public/images/typescript-3d.png

564 KB
Loading

public/logos/front-in-maringa.svg

+28
Loading

src/app/app.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import {EventHandler, FormControl, LayerSchema, Schema} from '@interfaces'
22
import {Form, Canvas, Sidenav, Accordion, DownloadButton} from '@elements'
33
import {PresentationForm} from '@components/presentation'
44
import {ThemeToggle} from '@components/theme'
5+
import {TitleBar} from '@elements/title-bar'
56
import {onFormChange} from '@events'
7+
import {dispatch, h} from '@utils'
68
import {use} from '@websqnl/di'
7-
import {h} from '@utils'
9+
import {login} from '@store'
810
import {
911
onSponsorAdded,
1012
onSponsorCreated,
@@ -16,7 +18,8 @@ import {
1618
onPresentationHandled,
1719
onPresentationSubmitted,
1820
} from '@events/presentation'
19-
import { TitleBar } from '@elements/title-bar'
21+
22+
dispatch(login({username: 'user', password: 'pass'}))
2023

2124
export const loadApp = (container: HTMLElement) => {
2225
const canvas = use(Canvas)

src/app/core/details-layer.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class DetailsLayer extends Layer implements DetailsSchema {
3333
.setColor('#f9f9f9')
3434

3535
async render() {
36-
this.context.clearRect(0, 0, this.width, this.height)
36+
3737

3838
let y = this.height / 4 - 12
3939

@@ -52,6 +52,8 @@ export class DetailsLayer extends Layer implements DetailsSchema {
5252
}
5353

5454
async renderDate(x: number, y: number) {
55+
this.context.clearRect(0, 0, this.width, this.height)
56+
5557
if (!this.date.isEmpty) {
5658
await this.calendar.render()
5759
this.context.drawImage(this.calendar, x, y)

src/app/core/grid-layer.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ export class GridLayer extends Layer {
2323
}
2424

2525
async render() {
26-
this.context.clearRect(0, 0, this.width, this.height)
26+
2727
const col = this.width / this.size
2828
const row = this.height / this.size
2929

30+
this.context.clearRect(0, 0, this.width, this.height)
31+
3032
for (let x = 0; x < this.size; x++) {
3133
for (let y = 0; y < this.size; y++) {
3234
const path = new Path2D()

src/app/core/image-layer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ export class ImageLayer extends Layer {
2020
}
2121

2222
async render() {
23-
this.context.canvas.width = this.context.canvas.width
2423
if (!this.#hasNoImage(this.#image.src)) {
2524
return this.#image.decode().then(() => {
25+
this.context.clearRect(0, 0, this.width, this.height)
2626
this.context.drawImage(this.#image, 0, 0, this.width, this.height)
2727
})
2828
}

src/app/core/photo-frame.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ export class PhotoFrameLayer extends Layer {
1010
}
1111

1212
async render() {
13-
this.context.clearRect(0, 0, this.width, this.height)
14-
1513
return this.#image.decode().then(() => {
14+
this.context.clearRect(0, 0, this.width, this.height)
1615
this.context.drawImage(this.#image, 0, 0)
1716
})
1817
}

src/app/core/photo-layer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ export class PhotoLayer extends Layer {
3737
}
3838

3939
async render() {
40-
this.context.clearRect(0, 0, this.width, this.height)
41-
4240
if (!this.#hasNoImage(this.#image.src)) {
4341
return this.#image.decode().then(() => {
4442
const {width, height} = this.#image
43+
44+
this.context.clearRect(0, 0, this.width, this.height)
4545
this.context.drawImage(this.#image, 8, 8, width, height)
4646
})
4747
}

src/app/core/presentation-layer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export class PresentationLayer extends Layer implements PresentationSchema {
2929
.setColor('#D9D9D9')
3030

3131
async render() {
32-
this.context.clearRect(0, 0, this.width, this.height)
33-
3432
await this.photo.render().then(() => {
33+
this.context.clearRect(0, 0, this.width, this.height)
34+
3535
this.context.drawImage(
3636
this.photo,
3737
this.photo.position.x,

src/app/store/actions.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {action} from '@utils/state'
2+
3+
export interface Login {
4+
username: string
5+
password: string
6+
}
7+
8+
export interface Logged {
9+
accressToken: string
10+
}
11+
12+
export const login = action<Login>('Login')
13+
export const loginSuccess = action<Logged>('Login Success')
14+
export const loginError = action<DOMException>('Login Error')

src/app/store/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './actions';
2+
export * from './selectors';
3+
export * from './subscribers';

src/app/store/selectors.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import {Logged, Login} from './actions'
2+
import {select} from '@utils/state'
3+
4+
export const onLogin = select<Login>('Login')
5+
export const onLoginSuccess = select<Logged>('Login Success')
6+
export const onLoginError = select<DOMException>('Login Error')

src/app/store/subscribers.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import {onLogin, onLoginSuccess, onLoginError} from './selectors'
2+
import {loginError, loginSuccess} from './actions'
3+
import {dispatch} from '@utils/state'
4+
5+
onLogin(({username, password}) => {
6+
console.log(username, password)
7+
8+
if (username === 'user' && password === 'pass') {
9+
dispatch(loginSuccess({accressToken: btoa(username + password)}))
10+
} else {
11+
dispatch(loginError(new DOMException('Login failure')))
12+
}
13+
})
14+
15+
onLoginSuccess((value) => {
16+
console.log(value.accressToken)
17+
})
18+
19+
onLoginError((value) => {
20+
console.log(value)
21+
})

src/app/utils/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './decorators';
2+
export * from './state';
23
export * from './writes';
34
export * from './async';
45
export * from './data-from-form';

src/app/utils/state/action.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {Callback} from '@interfaces/common'
2+
3+
export class Action<T> {
4+
constructor(public type: string, public value: T) {}
5+
}
6+
7+
export const action = <T>(type: string) => {
8+
return (value: T) => {
9+
return new (class extends Action<T> {
10+
constructor() {
11+
super(type, value)
12+
}
13+
})()
14+
}
15+
}
16+
17+
const actions = new Map<string, Set<Callback<any>>>()
18+
19+
export const setAction = <T>(type: string, callback: Callback<T>) => {
20+
const callbacks = getAction<T>(type)
21+
actions.set(type, callbacks.add(callback))
22+
}
23+
24+
export const getAction = <T>(type: string) => {
25+
return actions.get(type) ?? new Set<Callback<T>>()
26+
}

src/app/utils/state/dispatch.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {Action, getAction} from './action'
2+
3+
export const dispatch = <T>(action: Action<T>) => {
4+
for (const callback of getAction(action.type)) {
5+
callback(action.value)
6+
}
7+
}

src/app/utils/state/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './action';
2+
export * from './dispatch';
3+
export * from './select';

src/app/utils/state/select.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {Callback} from '@interfaces/common'
2+
import {setAction} from './action'
3+
4+
export const select = <T>(type: string) => {
5+
return (callback: Callback<T>) => {
6+
setAction(type, callback)
7+
}
8+
}

src/config.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const logos = [
112112
['Agile', 'logos/agile.svg'],
113113
['Curitiba', 'logos/curitiba.svg'],
114114
['Delphi', 'logos/delphi.svg'],
115-
['Geral', 'logos/geral.svg'],
115+
['Front In', 'logos/front-in-maringa.svg'],
116116
['NodeJS', 'logos/nodejs.svg'],
117117
['PHP', 'logos/php.svg'],
118118
['Rust', 'logos/rust.svg'],
@@ -121,12 +121,15 @@ const logos = [
121121

122122
const backgrounds = [
123123
['Github', 'images/github-wall.svg'],
124-
['Aspiral', 'images/bermuda-circle.svg'],
125-
['Colmeia', 'images/hive.svg'],
126124
['NodeJS 3D', 'images/nodejs-3d.png'],
127125
['PHP 3D', 'images/php-3d.png'],
128126
['Rust 3D', 'images/rust-3d.png'],
129-
['Front In', 'images/front-in-maringa-3d.png'],
127+
['Front In 3D', 'images/front-in-maringa-3d.png'],
128+
['TypeScript 3D', 'images/typescript-3d.png'],
129+
['Delphi 3D', 'images/delphi-3d.png'],
130+
['Silício', 'images/silicio.svg'],
131+
['Colmeia', 'images/hive.svg'],
132+
['Circulos', 'images/bermuda-circle.svg'],
130133
]
131134

132135
export const config: Config = {
@@ -208,7 +211,7 @@ export const formControl: FormControl = {
208211

209212
formControl.grid.add(
210213
new CheckboxLabel('Mostrar', 'gridActive', 'true', config.grid.active),
211-
new SliderLabel('Quantidade', 'grid', config.grid.tile)
214+
new SliderLabel('Tamanho', 'grid', config.grid.tile)
212215
)
213216

214217
formControl.logo.add(

src/scss/_input.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// system-ui,
1010
// -apple-system
1111
// );
12-
// font-size: 16px;
12+
// font-size: 0.9em;
1313
// line-height: 1.5;
1414
overflow: hidden;
1515
}
@@ -149,7 +149,7 @@
149149
system-ui,
150150
-apple-system
151151
);
152-
font-size: 16px;
152+
font-size: 0.9em;
153153
line-height: 1.5;
154154
overflow: hidden;
155155
}
@@ -366,7 +366,7 @@
366366
system-ui,
367367
-apple-system
368368
);
369-
font-size: 16px;
369+
font-size: 0.9em;
370370
line-height: 1.5;
371371
overflow: hidden;
372372
}

src/scss/_sidenav.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ $width__sidenav: 420px;
7979
fieldset,
8080
form > button,
8181
form > label {
82-
margin: 0.6em 1em;
82+
margin: 0.6em;
8383
}
8484

8585
details section {

src/style.scss

+9-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ body {
1616
:root {
1717
font-family: Mukta, sans-serif;
1818
line-height: 1.5;
19-
font-size: 1.2em;
19+
font-size: 1.1em;
2020
font-weight: 400;
2121

2222
color: #13b52b;
@@ -50,7 +50,7 @@ body {
5050
height: env(titlebar-area-height, 50px);
5151
width: env(titlebar-area-width, 100%);
5252
-webkit-app-region: drag;
53-
53+
5454
color: rgb(var(--cw-surface-rgb));
5555

5656
display: flex;
@@ -70,14 +70,14 @@ body {
7070

7171
> aside {
7272
min-width: var(--cw-sidenav-width);
73-
73+
7474
max-height: 100vh;
7575
overflow-x: auto;
7676

7777
transition: margin 400ms ease-in-out;
7878

79-
margin-left: calc(-420px - 2em);
80-
79+
margin-left: calc(var(--cw-sidenav-width) * -1 - 2px);
80+
8181
&.is-open {
8282
margin-left: 0;
8383
}
@@ -112,7 +112,6 @@ canvas {
112112
top: 1.5em;
113113
left: 1em;
114114
z-index: 1;
115-
116115
}
117116
.cw-theme-toggle {
118117
position: fixed;
@@ -134,7 +133,7 @@ canvas {
134133
}
135134

136135
.form-group {
137-
margin: 16px;
136+
margin: 0.6em;
138137
display: flex;
139138
flex-flow: row wrap;
140139
gap: 16px;
@@ -148,14 +147,14 @@ fieldset {
148147
display: flex;
149148
flex-flow: row wrap;
150149
border-radius: 0.4em;
151-
padding: 1.8em 2.2em 2.2em;
150+
padding: 1.4em 1.8em 1.8em;
152151
border: solid 2px rgba(var(--cw-onsurface-rgb, 0, 0, 0), 0.6);
153-
gap: 1em 2em;
152+
gap: 1em;
154153
legend {
155154
padding: 0 0.5em;
156155
}
157156

158157
> label {
159-
width: 120px;
158+
width: 140px;
160159
}
161160
}

tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"@utils": ["src/app/utils/index.ts"],
3333
"@core/*": ["src/core/*"],
3434
"@core": ["src/core/index.ts"],
35-
"@models/*": ["src/app/core/*"],
36-
"@models": ["src/app/core/index.ts"],
35+
"@store/*": ["src/app/store/*"],
36+
"@store": ["src/app/store/index.ts"],
3737
"@events/*": ["src/app/events/*"],
3838
"@events": ["src/app/events/index.ts"],
3939
"@elements/*": ["src/app/elements/*"],

0 commit comments

Comments
 (0)