Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions packages/core/test/fixtures/gea-elements-inline-alert/Alerts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { Store } from '@geastack/core'
import { InlineAlert, type InlineAlertVariant } from '@geastack/elements'

// One alert per behavior the native test checks. The app owns visibility:
// only the error alert is removed when it reports onDismiss.
class AlertsStore extends Store {
installs = 0
dismissCalls = 0
errorOpen = true
plainVariant: InlineAlertVariant = 'error'
}

const alerts = new AlertsStore()

export function Alerts() {
return (
<div class="alerts">
<InlineAlert
id="alert-info"
class="alert-info"
title="Update ready"
message="Version 2 is ready to install."
actionLabel="Install"
onAction={() => {
alerts.installs = alerts.installs + 1
}}
/>
<InlineAlert
id="alert-success"
class="alert-success"
variant="success"
title={undefined}
message="Settings saved."
dismissible={true}
onDismiss={() => {
alerts.dismissCalls = alerts.dismissCalls + 1
}}
/>
<InlineAlert
id="alert-warning"
class="alert-warning narrow"
variant="warning"
message="The battery is low. Connect the charger soon or the device will turn off."
/>
{alerts.errorOpen ? (
<InlineAlert
id="alert-error"
class="alert-error"
variant="error"
title="Yükleme başarısız"
severityLabel="Hata"
message="Dosya gönderilemedi."
dismissible={true}
dismissLabel="Kapat"
onDismiss={() => {
alerts.errorOpen = false
}}
/>
) : null}
<InlineAlert id="alert-plain" class="alert-plain" variant={alerts.plainVariant} message="No connection." />
<InlineAlert
id="alert-empty"
class="alert-empty"
variant="info"
title=""
message=""
actionLabel=""
severityLabel=""
dismissible={true}
dismissLabel=""
/>
<InlineAlert
id="alert-pair"
class="alert-pair"
variant="success"
message="Item deleted."
actionLabel="Undo"
onAction={() => {
alerts.installs = alerts.installs + 100
}}
dismissible={true}
dismissLabel="Close"
/>
<InlineAlert
id="alert-both"
class="alert-both narrow"
variant="warning"
title="Storage is almost full on this device"
message="Free some space."
actionLabel="Free up space"
onAction={() => {
alerts.installs = alerts.installs + 10
}}
dismissible={true}
dismissLabel="Later"
/>
<button
class="downgrade"
onClick={() => {
alerts.plainVariant = 'warning'
}}
>
Downgrade
</button>
<span class="status">{'installs=' + alerts.installs + ' dismissCalls=' + alerts.dismissCalls}</span>
</div>
)
}
12 changes: 12 additions & 0 deletions packages/core/test/fixtures/gea-elements-inline-alert/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@geastack/core'
import { Alerts } from './Alerts'

export class App extends Component {
template() {
return (
<div class="app">
<Alerts />
</div>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { mount } from '@geastack/core'
import { App } from './App'
import './styles.css'

mount(App)
19 changes: 19 additions & 0 deletions packages/core/test/fixtures/gea-elements-inline-alert/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.app {
width: 100vw;
height: 100vh;
}

.alerts {
display: flex;
flex-direction: column;
gap: 8px;
padding: 8px;
}

.narrow {
width: 200px;
}

.status {
font-size: 14px;
}
9 changes: 9 additions & 0 deletions packages/core/test/run-gea-elements-inline-alert-pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
exec "$ROOT/packages/core/test/run-gea-native-app-pipeline.sh" \
"gea-elements-inline-alert-pipeline" \
"$ROOT/packages/core/test/fixtures/gea-elements-inline-alert" \
"index.tsx" \
"packages/core/test/test_gea_elements_inline_alert_main.cpp"
Loading
Loading