Skip to content

Commit

Permalink
Merge pull request #5 from alizarazot/welcome
Browse files Browse the repository at this point in the history
Añadir bienvenida
  • Loading branch information
alizarazot authored May 23, 2024
2 parents 2b83ebe + d26e07e commit d5ae25c
Show file tree
Hide file tree
Showing 2 changed files with 282 additions and 34 deletions.
215 changes: 215 additions & 0 deletions src/internal/pane/welcome.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
import { LitElement, css, html } from "lit";
import { customElement, state } from "lit/decorators.js";

import {
IgcIconButtonComponent,
defineComponents,
registerIcon,
} from "igniteui-webcomponents";

import iconArrowBack from "@material-symbols/svg-400/rounded/arrow_back.svg";
import iconArrowForward from "@material-symbols/svg-400/rounded/arrow_forward.svg";

@customElement("pane-welcome")
export class PaneWelcome extends LitElement {
static override styles = css`
:host {
user-select: none;
}
.container {
font-family: sans-serif;
color: white;
height: 100vh;
box-sizing: border-box;
transition: all linear 3s;
display: grid;
grid-template-areas:
"back title forward"
"back desc forward";
}
.title,
.desc {
display: block;
text-align: center;
margin: 30px;
}
.title {
grid-area: title;
font-size: 60px;
}
.desc {
grid-area: desc;
font-size: 35px;
}
igc-icon-button,
igc-icon-button::part(base) {
height: 100%;
width: 15vw;
background-color: transparent;
border-radius: 0;
}
igc-icon-button::part(base):hover {
background-color: rgba(0, 0, 0, 0.2);
box-shadow: none;
}
igc-icon-button::part(base):active {
background-color: rgba(0, 0, 0, 0.4);
box-shadow: none;
}
igc-icon-button::part(base):focus {
box-shadow: none;
}
[name="arrow-back"] {
grid-area: back;
}
[name="arrow-forward"] {
grid-area: forward;
}
@media (max-width: 700px) {
.container {
grid-template-areas:
"title title"
"desc desc"
"back forward";
}
igc-icon-button,
igc-icon-button::part(base) {
width: 50vw;
}
}
@media (max-width: 1200px) {
.title {
font-size: 40px;
}
.desc {
font-size: 20px;
}
}
@media (max-width: 330px) {
.title,
.desc {
margin: 10px;
}
.title {
font-size: 30px;
}
.desc {
font-size: 16px;
}
}
`;

override connectedCallback(): void {
super.connectedCallback();

defineComponents(IgcIconButtonComponent);

registerIcon("arrow-back", iconArrowBack);
registerIcon("arrow-forward", iconArrowForward);

if (localStorage.getItem("no-welcome") === "1") {
this._removeWelcome();
}
}

@state()
private _screenIndex = 0;

protected override render(): unknown {
return html`
<div
class="container"
style="background-color: ${screens[this._screenIndex].color}"
>
<span class="title">${screens[this._screenIndex].title}</span>
<span class="desc">${screens[this._screenIndex].desc}</span>
<igc-icon-button
name="arrow-back"
@click=${() => {
if (this._screenIndex > 0) {
this._screenIndex--;
}
}}
></igc-icon-button>
<igc-icon-button
name="arrow-forward"
@click=${() => {
if (this._screenIndex < screens.length - 1) {
this._screenIndex++;
return;
}
this._removeWelcome();
}}
></igc-icon-button>
</div>
`;
}

private _removeWelcome() {
this.dispatchEvent(new Event("finish-introduction"));
localStorage.setItem("no-welcome", "1");
}
}

declare global {
interface HTMLElementTagNameMap {
"pane-welcome": PaneWelcome;
}
}

class Screen {
constructor(
public color: string,
public title: string,
public desc: string,
) {}
}

const screens = [
new Screen(
"#0078d7",
"¡Derriba barreras de comunicación!",
"Genera un impacto positivo al facilitar la inclusión y la accesibilidad para las personas sordas en tu entorno.",
),
new Screen(
"#d13438",
"¡Desarrolla nuevas habilidades!",
"Amplía tus perspectivas al desarrollar una nueva forma de comunicación y expresión.",
),
new Screen(
"#038387",
"¡Abre nuevas oportunidades!",
"Contribuye a la sociedad al participar en proyectos de inclusión y ayudar a crear una sociedad más justa.",
),
new Screen(
"#c30052",
"¡Experimenta la satisfacción personal!",
"Contribuye a una causa noble al apoyar a la comunidad sorda y luchar por sus derechos.",
),
new Screen(
"#6b69d6",
"¡Un idioma único y fascinante!",
"¡Anímate a aprender Lengua de Señas Colombiana y descubre un mundo de nuevas posibilidades!",
),
];
101 changes: 67 additions & 34 deletions src/my-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ import "igniteui-webcomponents/themes/light/fluent.css";
import iconMenu from "@material-symbols/svg-400/rounded/menu.svg";
import iconHome from "@material-symbols/svg-400/rounded/home.svg";
import iconTrophy from "@material-symbols/svg-400/rounded/trophy.svg";
import iconStar from "@material-symbols/svg-400/rounded/star.svg";

import * as logging from "pkg/logging";

import { registerServiceWorker } from "internal/service-worker";

import "internal/pane/welcome.ts";
import "internal/pane/home.ts";
import "internal/pane/lesson.ts";

import type { PaneHome } from "internal/pane/home.ts";
import type { PaneWelcome } from "internal/pane/welcome.ts";
import type { PaneLesson } from "internal/pane/lesson.ts";

import { currentSession } from "internal/session";
Expand All @@ -33,12 +36,17 @@ import type { Lesson } from "internal/lesson";
@customElement("my-element")
export class MyElement extends LitElement {
static override styles = css`
:host {
:host,
#root-pane {
display: flex;
flex-direction: column;
height: 100vh;
}
#root-pane[hidden=""] {
display: none;
}
.pane {
flex-grow: 1;
overflow-y: auto;
Expand All @@ -60,6 +68,7 @@ export class MyElement extends LitElement {
registerIcon("menu", iconMenu);
registerIcon("home", iconHome);
registerIcon("trophy", iconTrophy);
registerIcon("star", iconStar);

registerServiceWorker();
}
Expand All @@ -70,41 +79,65 @@ export class MyElement extends LitElement {
@query("igc-nav-drawer", true)
private _navDrawer!: IgcNavDrawerComponent;

@query("#root-pane")
private _rootPane!: HTMLDivElement;
@query("pane-welcome")
private _paneWelcome!: PaneWelcome;

override render() {
return html`
<igc-navbar>
<igc-icon
name="menu"
slot="start"
@click=${() => {
this._navDrawer.show();
}}
></igc-icon>
<h1>The Sign Link</h1>
<igc-avatar
slot="end"
shape="circle"
src=${this._currentSession.photo}
alt="User photo"
>
</igc-avatar>
</igc-navbar>
<igc-nav-drawer>
<igc-nav-drawer-header-item> The Sign Link </igc-nav-drawer-header-item>
<igc-nav-drawer-item @click=${this.showHome}>
<igc-icon slot="icon" name="home"></igc-icon>
<span slot="content">Inicio</span>
</igc-nav-drawer-item>
<igc-nav-drawer-item>
<igc-icon slot="icon" name="trophy"></igc-icon>
<span slot="content">Clasificación</span>
</igc-nav-drawer-item>
</igc-nav-drawer>
<div class="pane">
<pane-home @start-lesson=${this._handleStartLesson}></pane-home>
<pane-lesson hidden></pane-lesson>
<pane-welcome
@finish-introduction=${() => {
this._rootPane.removeAttribute("hidden");
this._paneWelcome.setAttribute("hidden", "");
}}
></pane-welcome>
<div id="root-pane" hidden>
<igc-navbar>
<igc-icon
name="menu"
slot="start"
@click=${() => {
this._navDrawer.show();
}}
></igc-icon>
<h1>The Sign Link</h1>
<igc-avatar
slot="end"
shape="circle"
src=${this._currentSession.photo}
alt="User photo"
>
</igc-avatar>
</igc-navbar>
<igc-nav-drawer>
<igc-nav-drawer-header-item>
The Sign Link
</igc-nav-drawer-header-item>
<igc-nav-drawer-item @click=${this.showHome}>
<igc-icon slot="icon" name="home"></igc-icon>
<span slot="content">Inicio</span>
</igc-nav-drawer-item>
<igc-nav-drawer-item>
<igc-icon slot="icon" name="trophy"></igc-icon>
<span slot="content">Clasificación</span>
</igc-nav-drawer-item>
<igc-nav-drawer-item
@click=${() => {
this._paneWelcome.removeAttribute("hidden");
this._navDrawer.hide();
}}
>
<igc-icon slot="icon" name="star"></igc-icon>
<span slot="content">Motivación</span>
</igc-nav-drawer-item>
</igc-nav-drawer>
<div class="pane">
<pane-home @start-lesson=${this._handleStartLesson}></pane-home>
<pane-lesson hidden></pane-lesson>
</div>
</div>
`;
}
Expand Down

0 comments on commit d5ae25c

Please sign in to comment.