Repository navigation
Add an InlineAlert demo app #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
moersoy
wants to merge
1
commit into
geastack:main
Choose a base branch
from
moersoy:apps/inline-alert
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import { Component } from '@geastack/core' | ||
| import { InlineAlert } from '@geastack/elements' | ||
| import { demo } from '../stores/DemoStore' | ||
|
|
||
| // Each alert sits in its own class component that reads the store, the way | ||
| // e-reader's OpeningModal does, with an element as the template's root. In | ||
| // a native build, a component inside a conditional branch keeps the props it | ||
| // was first built with, and so does a class whose template root is the | ||
| // InlineAlert itself; this shape follows the store. | ||
| // The language switch changes every text, including the severity labels, to | ||
| // show localized content wrapping in the same layout. With the built-in | ||
| // bitmap font, pixel targets draw the Turkish letters as `?`. | ||
|
|
||
| class InfoAlert extends Component { | ||
| template() { | ||
| return ( | ||
| <div> | ||
| <InlineAlert | ||
| id="demo-info" | ||
| class="demo-alert" | ||
| title={demo.turkish ? 'Güncelleme hazır' : 'Update ready'} | ||
| message={demo.turkish ? 'Sürüm 2 yüklenmeye hazır.' : 'Version 2 is ready to install.'} | ||
| severityLabel={demo.turkish ? 'Bilgi' : undefined} | ||
| dismissible={true} | ||
| dismissLabel={demo.turkish ? 'Kapat' : undefined} | ||
| onDismiss={() => demo.dismiss('info')} | ||
| /> | ||
| </div> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| class SuccessAlert extends Component { | ||
| template() { | ||
| return ( | ||
| <div> | ||
| <InlineAlert | ||
| class="demo-alert" | ||
| variant="success" | ||
| message={demo.turkish ? 'Ayarlar kaydedildi.' : 'Settings saved.'} | ||
| severityLabel={demo.turkish ? 'Başarılı' : undefined} | ||
| dismissible={true} | ||
| dismissLabel={demo.turkish ? 'Kapat' : undefined} | ||
| onDismiss={() => demo.dismiss('success')} | ||
| /> | ||
| </div> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| class WarningAlert extends Component { | ||
| template() { | ||
| return ( | ||
| <div> | ||
| <InlineAlert | ||
| class="demo-alert demo-alert--narrow" | ||
| variant="warning" | ||
| message={ | ||
| demo.turkish | ||
| ? 'Pil zayıf. Cihaz kapanmadan önce şarj cihazını bağlayın.' | ||
| : 'The battery is low. Connect the charger before the device turns off.' | ||
| } | ||
| severityLabel={demo.turkish ? 'Uyarı' : undefined} | ||
| dismissible={true} | ||
| dismissLabel={demo.turkish ? 'Kapat' : undefined} | ||
| onDismiss={() => demo.dismiss('warning')} | ||
| /> | ||
| </div> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| class ErrorAlert extends Component { | ||
| template() { | ||
| return ( | ||
| <div> | ||
| <InlineAlert | ||
| class="demo-alert" | ||
| variant="error" | ||
| title={demo.turkish ? 'Yükleme başarısız' : 'Upload failed'} | ||
| message={(demo.turkish ? 'Deneme sayısı: ' : 'Retries: ') + demo.retries} | ||
| severityLabel={demo.turkish ? 'Hata' : undefined} | ||
| actionLabel={demo.turkish ? 'Tekrar dene' : 'Retry'} | ||
| onAction={() => demo.retry()} | ||
| dismissible={true} | ||
| dismissLabel={demo.turkish ? 'Kapat' : undefined} | ||
| onDismiss={() => demo.dismiss('error')} | ||
| /> | ||
| </div> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| export function Alerts() { | ||
| return ( | ||
| <div class="demo-alerts"> | ||
| {demo.infoOpen ? <InfoAlert /> : null} | ||
| {demo.successOpen ? <SuccessAlert /> : null} | ||
| {demo.warningOpen ? <WarningAlert /> : null} | ||
| {demo.errorOpen ? <ErrorAlert /> : null} | ||
| </div> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { Component } from '@geastack/core' | ||
| import { demo } from '../stores/DemoStore' | ||
| import { Alerts } from './Alerts' | ||
|
|
||
| export class App extends Component { | ||
| template() { | ||
| return ( | ||
| <div class="demo-app"> | ||
| <span class="demo-title">InlineAlert</span> | ||
| <Alerts /> | ||
| <div class="demo-buttons"> | ||
| <button class="demo-button" onClick={() => demo.toggleLanguage()}> | ||
| {demo.turkish ? 'English' : 'Türkçe'} | ||
| </button> | ||
| <button class="demo-button" onClick={() => demo.reset()}> | ||
| {demo.turkish ? 'Sıfırla' : 'Reset'} | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| /// <reference types="@geastack/core" /> | ||
| declare module '*.css' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { mount } from '@geastack/core' | ||
| import './styles.css' | ||
| import { App } from './components/App' | ||
|
|
||
| mount(App) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "name": "@geastack/example-inline-alert", | ||
| "type": "module", | ||
| "scripts": { | ||
| "check": "tsc --noEmit" | ||
| }, | ||
| "dependencies": { | ||
| "@geastack/core": "^0.1.41", | ||
| "@geastack/elements": "^0.1.6" | ||
| }, | ||
| "gea": { | ||
| "id": "inline-alert", | ||
| "name": "Inline Alert", | ||
| "entry": "index.tsx", | ||
| "runtime": "gea", | ||
| "targets": { | ||
| "web": true, | ||
| "esp32": false | ||
| }, | ||
| "launcher": { | ||
| "description": "inline alert variants", | ||
| "order": 999, | ||
| "hidden": true | ||
| } | ||
| }, | ||
| "private": true, | ||
| "license": "MIT", | ||
| "version": "0.1.0" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { Store } from '@geastack/core' | ||
| import type { InlineAlertVariant } from '@geastack/elements' | ||
|
|
||
| // The app owns which alerts are shown. InlineAlert only reports onDismiss, | ||
| // so dismissing one here removes it until Reset. | ||
| class DemoStore extends Store { | ||
| infoOpen = true | ||
| successOpen = true | ||
| warningOpen = true | ||
| errorOpen = true | ||
| turkish = false | ||
| retries = 0 | ||
|
|
||
| dismiss(variant: InlineAlertVariant): void { | ||
| if (variant === 'info') this.infoOpen = false | ||
| if (variant === 'success') this.successOpen = false | ||
| if (variant === 'warning') this.warningOpen = false | ||
| if (variant === 'error') this.errorOpen = false | ||
| } | ||
|
|
||
| retry(): void { | ||
| this.retries = this.retries + 1 | ||
| } | ||
|
|
||
| toggleLanguage(): void { | ||
| this.turkish = !this.turkish | ||
| } | ||
|
|
||
| reset(): void { | ||
| this.infoOpen = true | ||
| this.successOpen = true | ||
| this.warningOpen = true | ||
| this.errorOpen = true | ||
| this.retries = 0 | ||
| } | ||
| } | ||
|
|
||
| export const demo = new DemoStore() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| body { | ||
| background-color: #f6f3ea; | ||
| color: #171713; | ||
| font-family: 'Inter'; | ||
| } | ||
|
|
||
| .demo-app { | ||
| display: flex; | ||
| flex-direction: column; | ||
| padding: 24px; | ||
| gap: 12px; | ||
| } | ||
|
|
||
| .demo-title { | ||
| font-size: 28px; | ||
| font-weight: 700; | ||
| } | ||
|
|
||
| .demo-alerts { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 12px; | ||
| } | ||
|
|
||
| .demo-alert { | ||
| width: 100%; | ||
| } | ||
|
|
||
| .demo-alert--narrow { | ||
| width: 220px; | ||
| } | ||
|
|
||
| .demo-buttons { | ||
| display: flex; | ||
| flex-direction: row; | ||
| gap: 8px; | ||
| } | ||
|
|
||
| .demo-button { | ||
| width: 96px; | ||
| height: 44px; | ||
| background-color: #171713; | ||
| color: #ffffff; | ||
| font-size: 14px; | ||
| border-radius: 8px; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2022", | ||
| "module": "ESNext", | ||
| "moduleResolution": "Bundler", | ||
| "lib": [ | ||
| "ES2022" | ||
| ], | ||
| "strict": true, | ||
| "noEmit": true, | ||
| "skipLibCheck": true, | ||
| "jsx": "preserve", | ||
| "types": [] | ||
| }, | ||
| "include": [ | ||
| "**/*.tsx", | ||
| "**/*.d.ts", | ||
| "../../node_modules/@geajs/vite-plugin/gea-env.d.ts" | ||
| ], | ||
| "exclude": [ | ||
| "vite.config.ts" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Use an elements release that exports
InlineAlert.@geastack/elements^0.1.6does not exportInlineAlert, but this app imports it andInlineAlertVariant. A clean install therefore cannot type-check or build the demo. The reported compiler pass used a copy linked to the component branch. Release the component, then update this dependency and the lockfile to a version that contains its exports. (github.com)🤖 Prompt for AI Agents