Repository navigation
Add a ProgressBar demo app #3
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/progress-bar
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,49 @@ | ||
| import { Component } from '@geastack/core' | ||
| import { ProgressBar, progressFraction } from '@geastack/elements' | ||
| import { demo } from '../stores/DemoStore' | ||
|
|
||
| export class App extends Component { | ||
| // The buttons drive #demo-bar. The .demo-cases bars below them never change; | ||
| // they cover default props, a fractional value with an empty label, a | ||
| // negative range, an inverted range and a NaN value for core's pipeline test. | ||
| template() { | ||
| return ( | ||
| <div class="demo-app"> | ||
| <span class="demo-title">ProgressBar</span> | ||
| <ProgressBar | ||
| id="demo-bar" | ||
| class={{ 'demo-bar': true, 'demo-bar--narrow': !demo.wide }} | ||
| value={demo.value} | ||
| min={demo.min} | ||
| max={demo.max} | ||
| indeterminate={demo.busy} | ||
| reducedMotion={demo.still} | ||
| label={demo.label} | ||
| /> | ||
| <div class="demo-buttons"> | ||
| <button class="demo-button" onClick={() => demo.step(-25)}>Minus</button> | ||
| <button class="demo-button" onClick={() => demo.step(25)}>Plus</button> | ||
| <button class="demo-button" onClick={() => demo.setValue(150)}>Over</button> | ||
| <button class="demo-button" onClick={() => demo.setValue(-20)}>Under</button> | ||
| </div> | ||
| <div class="demo-buttons"> | ||
| <button class="demo-button" onClick={() => demo.zeroRange()}>Zero range</button> | ||
| <button class="demo-button" onClick={() => demo.toggleBusy()}>Busy</button> | ||
| <button class="demo-button" onClick={() => demo.toggleStill()}>Still</button> | ||
| <button class="demo-button" onClick={() => demo.toggleWide()}>Resize</button> | ||
| </div> | ||
| <div class="demo-buttons"> | ||
| <button class="demo-button" onClick={() => demo.reset()}>Reset</button> | ||
| </div> | ||
| <div class="demo-cases"> | ||
| <ProgressBar class="demo-case demo-case--defaults" /> | ||
| <ProgressBar class="demo-case demo-case--default-range" value={25} /> | ||
| <ProgressBar class="demo-case demo-case--fraction" value={33.34} label="" /> | ||
| <ProgressBar class="demo-case demo-case--negative" value={-75.5} min={-100.5} max={-50.5} /> | ||
| <ProgressBar class="demo-case demo-case--inverted" value={60} min={100} max={0} /> | ||
| <ProgressBar class="demo-case demo-case--nan" value={NaN} label={'NaN gives [' + progressFraction(NaN, 0, 100) + ']'} /> | ||
| </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-progress-bar", | ||
| "type": "module", | ||
| "scripts": { | ||
| "check": "tsc --noEmit" | ||
| }, | ||
| "dependencies": { | ||
| "@geastack/core": "^0.1.41", | ||
| "@geastack/elements": "^0.1.6" | ||
| }, | ||
| "gea": { | ||
| "id": "progress-bar", | ||
| "name": "Progress Bar", | ||
| "entry": "index.tsx", | ||
| "runtime": "gea", | ||
| "targets": { | ||
| "web": true, | ||
| "esp32": false | ||
| }, | ||
| "launcher": { | ||
| "description": "progress bar states", | ||
| "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,61 @@ | ||
| import { Store } from '@geastack/core' | ||
|
|
||
| // Every button drives one of the cases the ProgressBar has to handle, so the | ||
| // app doubles as the fixture for core's progress-bar pipeline test. | ||
| export class DemoStore extends Store { | ||
| value = 40 | ||
| min = 0 | ||
| max = 100 | ||
| busy = false | ||
| still = false | ||
| wide = true | ||
|
|
||
| // ProgressBar clamps what it draws, not the app's value, so the app keeps its | ||
| // own value in range. Over and Under bypass this on purpose to exercise the | ||
| // bar's clamping. | ||
| step(delta: number) { | ||
| let next = this.value + delta | ||
| if (next > this.max) next = this.max | ||
| if (next < this.min) next = this.min | ||
| this.value = next | ||
| } | ||
|
|
||
| setValue(next: number) { | ||
| this.value = next | ||
| } | ||
|
|
||
| // min == max leaves the bar nothing to divide by; it must draw empty, not NaN. | ||
| zeroRange() { | ||
| this.min = 50 | ||
| this.max = 50 | ||
| } | ||
|
|
||
| reset() { | ||
| this.value = 40 | ||
| this.min = 0 | ||
| this.max = 100 | ||
| this.busy = false | ||
| this.still = false | ||
| this.wide = true | ||
| } | ||
|
|
||
| toggleBusy() { | ||
| this.busy = !this.busy | ||
| } | ||
|
|
||
| toggleStill() { | ||
| this.still = !this.still | ||
| } | ||
|
|
||
| toggleWide() { | ||
| this.wide = !this.wide | ||
| } | ||
|
|
||
| get label(): string { | ||
| if (this.busy) return 'Working' | ||
| const range = 'value ' + this.value + ' of ' + this.min + '-' + this.max | ||
| return this.max > this.min ? range : range + ' (zero range)' | ||
| } | ||
| } | ||
|
|
||
| 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,51 @@ | ||
| body { | ||
| background-color: #f6f3ea; | ||
| color: #171713; | ||
| font-family: 'Inter'; | ||
| } | ||
|
|
||
| .demo-app { | ||
| display: flex; | ||
| flex-direction: column; | ||
| padding: 24px; | ||
| gap: 20px; | ||
| } | ||
|
|
||
| .demo-title { | ||
| font-size: 28px; | ||
| font-weight: 700; | ||
| } | ||
|
|
||
| .demo-bar { | ||
| width: 300px; | ||
| } | ||
|
|
||
| .demo-bar--narrow { | ||
| width: 150px; | ||
| } | ||
|
|
||
| .demo-buttons { | ||
| display: flex; | ||
| flex-direction: row; | ||
| flex-wrap: wrap; | ||
| gap: 8px; | ||
| } | ||
|
|
||
| .demo-button { | ||
| width: 70px; | ||
| height: 44px; | ||
| background-color: #171713; | ||
| color: #ffffff; | ||
| font-size: 14px; | ||
| border-radius: 8px; | ||
| } | ||
|
|
||
| .demo-cases { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 12px; | ||
| } | ||
|
|
||
| .demo-case { | ||
| width: 300px; | ||
| } |
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
Make the declared elements dependency capable of building this app.
The published
@geastack/elementspackage allowed by^0.1.6does not exportProgressBar. A fresh workspace install therefore cannot passnpm run checkwithout linking the companion core branch. Coordinate the elements release and update this dependency before treating the app as independently buildable. (github.com)🤖 Prompt for AI Agents