Skip to content

Commit

Permalink
feat: melhora alinhamento na sidenav e adiciona mais fundos 3D
Browse files Browse the repository at this point in the history
  • Loading branch information
guiseek committed Aug 15, 2024
1 parent 49b052c commit 9ec0af4
Show file tree
Hide file tree
Showing 30 changed files with 280 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build --base='creative-writer'",
"build": "tsc && vite build --base='/creative-writer'",
"preview": "vite preview",
"test": "jest"
},
Expand Down
Binary file added public/images/delphi-3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/front-in-maringa-3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/nodejs-3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/php-3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/rust-3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
122 changes: 122 additions & 0 deletions public/images/silicio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/typescript-3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions public/logos/front-in-maringa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import {EventHandler, FormControl, LayerSchema, Schema} from '@interfaces'
import {Form, Canvas, Sidenav, Accordion, DownloadButton} from '@elements'
import {PresentationForm} from '@components/presentation'
import {ThemeToggle} from '@components/theme'
import {TitleBar} from '@elements/title-bar'
import {onFormChange} from '@events'
import {dispatch, h} from '@utils'
import {use} from '@websqnl/di'
import {h} from '@utils'
import {login} from '@store'
import {
onSponsorAdded,
onSponsorCreated,
Expand All @@ -16,7 +18,8 @@ import {
onPresentationHandled,
onPresentationSubmitted,
} from '@events/presentation'
import { TitleBar } from '@elements/title-bar'

dispatch(login({username: 'user', password: 'pass'}))

export const loadApp = (container: HTMLElement) => {
const canvas = use(Canvas)
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/details-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class DetailsLayer extends Layer implements DetailsSchema {
.setColor('#f9f9f9')

async render() {
this.context.clearRect(0, 0, this.width, this.height)


let y = this.height / 4 - 12

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

async renderDate(x: number, y: number) {
this.context.clearRect(0, 0, this.width, this.height)

if (!this.date.isEmpty) {
await this.calendar.render()
this.context.drawImage(this.calendar, x, y)
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/grid-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ export class GridLayer extends Layer {
}

async render() {
this.context.clearRect(0, 0, this.width, this.height)

const col = this.width / this.size
const row = this.height / this.size

this.context.clearRect(0, 0, this.width, this.height)

for (let x = 0; x < this.size; x++) {
for (let y = 0; y < this.size; y++) {
const path = new Path2D()
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/image-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export class ImageLayer extends Layer {
}

async render() {
this.context.canvas.width = this.context.canvas.width
if (!this.#hasNoImage(this.#image.src)) {
return this.#image.decode().then(() => {
this.context.clearRect(0, 0, this.width, this.height)
this.context.drawImage(this.#image, 0, 0, this.width, this.height)
})
}
Expand Down
3 changes: 1 addition & 2 deletions src/app/core/photo-frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ export class PhotoFrameLayer extends Layer {
}

async render() {
this.context.clearRect(0, 0, this.width, this.height)

return this.#image.decode().then(() => {
this.context.clearRect(0, 0, this.width, this.height)
this.context.drawImage(this.#image, 0, 0)
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/photo-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export class PhotoLayer extends Layer {
}

async render() {
this.context.clearRect(0, 0, this.width, this.height)

if (!this.#hasNoImage(this.#image.src)) {
return this.#image.decode().then(() => {
const {width, height} = this.#image

this.context.clearRect(0, 0, this.width, this.height)
this.context.drawImage(this.#image, 8, 8, width, height)
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/presentation-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export class PresentationLayer extends Layer implements PresentationSchema {
.setColor('#D9D9D9')

async render() {
this.context.clearRect(0, 0, this.width, this.height)

await this.photo.render().then(() => {
this.context.clearRect(0, 0, this.width, this.height)

this.context.drawImage(
this.photo,
this.photo.position.x,
Expand Down
14 changes: 14 additions & 0 deletions src/app/store/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {action} from '@utils/state'

export interface Login {
username: string
password: string
}

export interface Logged {
accressToken: string
}

export const login = action<Login>('Login')
export const loginSuccess = action<Logged>('Login Success')
export const loginError = action<DOMException>('Login Error')
3 changes: 3 additions & 0 deletions src/app/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './actions';
export * from './selectors';
export * from './subscribers';
6 changes: 6 additions & 0 deletions src/app/store/selectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {Logged, Login} from './actions'
import {select} from '@utils/state'

export const onLogin = select<Login>('Login')
export const onLoginSuccess = select<Logged>('Login Success')
export const onLoginError = select<DOMException>('Login Error')
21 changes: 21 additions & 0 deletions src/app/store/subscribers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {onLogin, onLoginSuccess, onLoginError} from './selectors'
import {loginError, loginSuccess} from './actions'
import {dispatch} from '@utils/state'

onLogin(({username, password}) => {
console.log(username, password)

if (username === 'user' && password === 'pass') {
dispatch(loginSuccess({accressToken: btoa(username + password)}))
} else {
dispatch(loginError(new DOMException('Login failure')))
}
})

onLoginSuccess((value) => {
console.log(value.accressToken)
})

onLoginError((value) => {
console.log(value)
})
1 change: 1 addition & 0 deletions src/app/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './decorators';
export * from './state';
export * from './writes';
export * from './async';
export * from './data-from-form';
Expand Down
26 changes: 26 additions & 0 deletions src/app/utils/state/action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {Callback} from '@interfaces/common'

export class Action<T> {
constructor(public type: string, public value: T) {}
}

export const action = <T>(type: string) => {
return (value: T) => {
return new (class extends Action<T> {
constructor() {
super(type, value)
}
})()
}
}

const actions = new Map<string, Set<Callback<any>>>()

export const setAction = <T>(type: string, callback: Callback<T>) => {
const callbacks = getAction<T>(type)
actions.set(type, callbacks.add(callback))
}

export const getAction = <T>(type: string) => {
return actions.get(type) ?? new Set<Callback<T>>()
}
7 changes: 7 additions & 0 deletions src/app/utils/state/dispatch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {Action, getAction} from './action'

export const dispatch = <T>(action: Action<T>) => {
for (const callback of getAction(action.type)) {
callback(action.value)
}
}
3 changes: 3 additions & 0 deletions src/app/utils/state/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './action';
export * from './dispatch';
export * from './select';
8 changes: 8 additions & 0 deletions src/app/utils/state/select.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {Callback} from '@interfaces/common'
import {setAction} from './action'

export const select = <T>(type: string) => {
return (callback: Callback<T>) => {
setAction(type, callback)
}
}
13 changes: 8 additions & 5 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const logos = [
['Agile', 'logos/agile.svg'],
['Curitiba', 'logos/curitiba.svg'],
['Delphi', 'logos/delphi.svg'],
['Geral', 'logos/geral.svg'],
['Front In', 'logos/front-in-maringa.svg'],
['NodeJS', 'logos/nodejs.svg'],
['PHP', 'logos/php.svg'],
['Rust', 'logos/rust.svg'],
Expand All @@ -121,12 +121,15 @@ const logos = [

const backgrounds = [
['Github', 'images/github-wall.svg'],
['Aspiral', 'images/bermuda-circle.svg'],
['Colmeia', 'images/hive.svg'],
['NodeJS 3D', 'images/nodejs-3d.png'],
['PHP 3D', 'images/php-3d.png'],
['Rust 3D', 'images/rust-3d.png'],
['Front In', 'images/front-in-maringa-3d.png'],
['Front In 3D', 'images/front-in-maringa-3d.png'],
['TypeScript 3D', 'images/typescript-3d.png'],
['Delphi 3D', 'images/delphi-3d.png'],
['Silício', 'images/silicio.svg'],
['Colmeia', 'images/hive.svg'],
['Circulos', 'images/bermuda-circle.svg'],
]

export const config: Config = {
Expand Down Expand Up @@ -208,7 +211,7 @@ export const formControl: FormControl = {

formControl.grid.add(
new CheckboxLabel('Mostrar', 'gridActive', 'true', config.grid.active),
new SliderLabel('Quantidade', 'grid', config.grid.tile)
new SliderLabel('Tamanho', 'grid', config.grid.tile)
)

formControl.logo.add(
Expand Down
6 changes: 3 additions & 3 deletions src/scss/_input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// system-ui,
// -apple-system
// );
// font-size: 16px;
// font-size: 0.9em;
// line-height: 1.5;
overflow: hidden;
}
Expand Down Expand Up @@ -149,7 +149,7 @@
system-ui,
-apple-system
);
font-size: 16px;
font-size: 0.9em;
line-height: 1.5;
overflow: hidden;
}
Expand Down Expand Up @@ -366,7 +366,7 @@
system-ui,
-apple-system
);
font-size: 16px;
font-size: 0.9em;
line-height: 1.5;
overflow: hidden;
}
Expand Down
2 changes: 1 addition & 1 deletion src/scss/_sidenav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ $width__sidenav: 420px;
fieldset,
form > button,
form > label {
margin: 0.6em 1em;
margin: 0.6em;
}

details section {
Expand Down
19 changes: 9 additions & 10 deletions src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ body {
:root {
font-family: Mukta, sans-serif;
line-height: 1.5;
font-size: 1.2em;
font-size: 1.1em;
font-weight: 400;

color: #13b52b;
Expand Down Expand Up @@ -50,7 +50,7 @@ body {
height: env(titlebar-area-height, 50px);
width: env(titlebar-area-width, 100%);
-webkit-app-region: drag;

color: rgb(var(--cw-surface-rgb));

display: flex;
Expand All @@ -70,14 +70,14 @@ body {

> aside {
min-width: var(--cw-sidenav-width);

max-height: 100vh;
overflow-x: auto;

transition: margin 400ms ease-in-out;

margin-left: calc(-420px - 2em);
margin-left: calc(var(--cw-sidenav-width) * -1 - 2px);

&.is-open {
margin-left: 0;
}
Expand Down Expand Up @@ -112,7 +112,6 @@ canvas {
top: 1.5em;
left: 1em;
z-index: 1;

}
.cw-theme-toggle {
position: fixed;
Expand All @@ -134,7 +133,7 @@ canvas {
}

.form-group {
margin: 16px;
margin: 0.6em;
display: flex;
flex-flow: row wrap;
gap: 16px;
Expand All @@ -148,14 +147,14 @@ fieldset {
display: flex;
flex-flow: row wrap;
border-radius: 0.4em;
padding: 1.8em 2.2em 2.2em;
padding: 1.4em 1.8em 1.8em;
border: solid 2px rgba(var(--cw-onsurface-rgb, 0, 0, 0), 0.6);
gap: 1em 2em;
gap: 1em;
legend {
padding: 0 0.5em;
}

> label {
width: 120px;
width: 140px;
}
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@utils": ["src/app/utils/index.ts"],
"@core/*": ["src/core/*"],
"@core": ["src/core/index.ts"],
"@models/*": ["src/app/core/*"],
"@models": ["src/app/core/index.ts"],
"@store/*": ["src/app/store/*"],
"@store": ["src/app/store/index.ts"],
"@events/*": ["src/app/events/*"],
"@events": ["src/app/events/index.ts"],
"@elements/*": ["src/app/elements/*"],
Expand Down

0 comments on commit 9ec0af4

Please sign in to comment.