# Notice

Source: https://ecosphere.dev/docs/feedback/notice (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

An inline notice with an icon, a body and one action, in four tones.

`import { EcoNotice } from "vue-ecosphere"`

## Notice

The icon sits with the first line; the action centres itself. Vertical spacing is the parent's job.

Vue (vue-ecosphere):

```vue
<EcoNotice
  title="You have used all 20 requests on your plan today."
  text="Your limit resets at 9:00 AM. Everything already submitted is unaffected, and nothing unsaved is lost."
  action="See plans"
  @action="openPlans"
/>
```

React (react-ecosphere):

```tsx
<EcoNotice
  title="You have used all 20 requests on your plan today."
  text="Your limit resets at 9:00 AM. Everything already submitted is unaffected, and nothing unsaved is lost."
  action="See plans"
  onAction={openPlans}
/>
```

## Tones

info for neutral news, success for something done, warning (the default) for a limit, danger for something that failed or cannot be undone. The words carry the meaning as well as the colour.

Vue (vue-ecosphere):

```vue
<EcoNotice tone="info" title="Term 2 starts on 6 January." text="Timetables publish to students a week before." />
<EcoNotice tone="success" title="Fees are reconciled." text="All 412 payments for October match the bank statement." />
<EcoNotice tone="warning" title="3 classes have no teacher." text="Students in them see an empty timetable slot." action="Assign" />
<EcoNotice tone="danger" title="The import failed." text="Row 18 has no admission number. Nothing was saved." action="Download report" />
```

React (react-ecosphere):

```tsx
<EcoNotice tone="info" title="Term 2 starts on 6 January." text="Timetables publish to students a week before." />
<EcoNotice tone="success" title="Fees are reconciled." text="All 412 payments for October match the bank statement." />
<EcoNotice tone="warning" title="3 classes have no teacher." text="Students in them see an empty timetable slot." action="Assign" />
<EcoNotice tone="danger" title="The import failed." text="Row 18 has no admission number. Nothing was saved." action="Download report" />
```

## Dismissible

The × only emits dismiss: remove the notice with v-if, and remember the choice if it should stay gone.

Vue (vue-ecosphere):

```vue
<EcoNotice
  v-if="showImport"
  tone="success"
  title="Imported 120 students."
  text="They can sign in once their guardians accept the invite."
  dismissible
  @dismiss="showImport = false"
/>
```

React (react-ecosphere):

```tsx
const [showImport, setShowImport] = useState(true);

{showImport && (
  <EcoNotice
    tone="success"
    title="Imported 120 students."
    text="They can sign in once their guardians accept the invite."
    dismissible
    onDismiss={() => setShowImport(false)}
  />
)}
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `string` | — | The fact, in bold, first. |
| `text` | `string` | — | What it means (the default slot overrides it). |
| `tone` | `"warning" \| "info" \| "success" \| "danger"` | "warning" | Colours the stripe, icon and action link. warning is the original look; info uses the accent. |
| `icon` | `string` | — | Leading icon (notice__i). Defaults to the tone's: information-line (warning, info), checkbox-circle-line (success), close-circle-line (danger). |
| `action` | `string` | — | One action link (notice__a); emits action. Or use the #action slot. |
| `dismissible` | `boolean` | false | Adds a small × (notice__x) that emits dismiss. The parent removes the notice. |
| `dismissLabel` | `string` | "Dismiss" | Accessible name of the × button. |
| `@action / @dismiss` | `() => void` | — | The action link was pressed / the × was pressed. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `string` | — | The fact, in bold, first. |
| `text` | `string` | — | What it means (children override it). |
| `tone` | `"warning" \| "info" \| "success" \| "danger"` | "warning" | Colours the stripe, icon and action link. warning is the original look; info uses the accent. |
| `icon` | `string` | — | Leading icon (notice__i). Defaults to the tone's: information-line (warning, info), checkbox-circle-line (success), close-circle-line (danger). |
| `action` | `ReactNode` | — | One action link (notice__a): text renders the link and calls onAction. A node instead replaces the link. |
| `dismissible` | `boolean` | false | Adds a small × (notice__x) that calls onDismiss. The parent removes the notice. |
| `dismissLabel` | `string` | "Dismiss" | Accessible name of the × button. |
| `onAction / onDismiss` | `() => void` | — | The action link was pressed / the × was pressed. |
