discourse/app/assets/stylesheets/desktop
Joffrey JAFFEUX abcdd8d367
DEV: FloatKit (#23312)
This PR introduces three new UI elements to Discourse codebase through an addon called "FloatKit":

- menu
- tooltip
- toast

Simple cases can be express with an API similar to DButton:

```hbs
<DTooltip
  @label={{i18n "foo.bar"}}
  @icon="check"
  @content="Something"
/>
```

More complex cases can use blocks:

```hbs
<DTooltip>
  <:trigger>
   {{d-icon "check"}}
   <span>{{i18n "foo.bar"}}</span>
  </:trigger>
  <:content>
   Something
  </:content>
</DTooltip>
```

You can manually show a tooltip using the `tooltip` service:

```javascript
const tooltipInstance = await this.tooltip.show(
  document.querySelector(".my-span"),
  options
)

// and later manually close or destroy it
tooltipInstance.close();
tooltipInstance.destroy();

// you can also just close any open tooltip through the service
this.tooltip.close();
```

The service also allows you to register event listeners on a trigger, it removes the need for you to manage open/close of a tooltip started through the service:

```javascript
const tooltipInstance = this.tooltip.register(
  document.querySelector(".my-span"),
  options
)

// when done you can destroy the instance to remove the listeners
tooltipInstance.destroy();
```

Note that the service also allows you to use a custom component as content which will receive `@data` and `@close` as args:

```javascript
const tooltipInstance = await this.tooltip.show(
  document.querySelector(".my-span"),
  {
    component: MyComponent,
    data: { foo: 1 }
  }
)
```

Menus are very similar to tooltips and provide the same kind of APIs:

```hbs
<DMenu @icon="plus" @label={{i18n "foo.bar"}}>
  <ul>
    <li>Foo</li>
    <li>Bat</li>
    <li>Baz</li>
  </ul>
</DMenu>
```

They also support blocks:

```hbs
<DMenu>
  <:trigger>
    {{d-icon "plus"}}
    <span>{{i18n "foo.bar"}}</span>
  </:trigger>
  <:content>
    <ul>
      <li>Foo</li>
      <li>Bat</li>
      <li>Baz</li>
    </ul>
  </:content>
</DMenu>
```

You can manually show a menu using the `menu` service:

```javascript
const menuInstance = await this.menu.show(
  document.querySelector(".my-span"),
  options
)

// and later manually close or destroy it
menuInstance.close();
menuInstance.destroy();

// you can also just close any open tooltip through the service
this.menu.close();
```

The service also allows you to register event listeners on a trigger, it removes the need for you to manage open/close of a tooltip started through the service:

```javascript
const menuInstance = this.menu.register(
   document.querySelector(".my-span"),
   options
)

// when done you can destroy the instance to remove the listeners
menuInstance.destroy();
```

Note that the service also allows you to use a custom component as content which will receive `@data` and `@close` as args:

```javascript
const menuInstance = await this.menu.show(
  document.querySelector(".my-span"),
  {
    component: MyComponent,
    data: { foo: 1 }
  }
)
```

Interacting with toasts is made only through the `toasts` service.

A default component is provided (DDefaultToast) and can be used through dedicated service methods:

- this.toasts.success({ ... });
- this.toasts.warning({ ... });
- this.toasts.info({ ... });
- this.toasts.error({ ... });
- this.toasts.default({ ... });

```javascript
this.toasts.success({
  data: {
    title: "Foo",
    message: "Bar",
    actions: [
      {
        label: "Ok",
        class: "btn-primary",
        action: (componentArgs) => {
          // eslint-disable-next-line no-alert
          alert("Closing toast:" + componentArgs.data.title);
          componentArgs.close();
        },
      }
    ]
  },
});
```

You can also provide your own component:

```javascript
this.toasts.show(MyComponent, {
  autoClose: false,
  class: "foo",
  data: { baz: 1 },
})
```

Co-authored-by: Martin Brennan <mjrbrennan@gmail.com>
Co-authored-by: Isaac Janzen <50783505+janzenisaac@users.noreply.github.com>
Co-authored-by: David Taylor <david@taylorhq.com>
Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2023-09-12 15:06:51 +02:00
..
admin DEV: Added support for custom site setting 'emoji_list' (#12414) 2021-04-07 15:32:05 +02:00
components DEV: FloatKit (#23312) 2023-09-12 15:06:51 +02:00
_index.scss DEV: remove old and experimental user menu styles (#21326) 2023-05-02 15:07:42 -04:00
admin_customize.scss UX: Editing theme name stays active when switching themes. 2019-04-23 14:57:14 +08:00
alert.scss FEATURE: update bootstrap mode notice to add invite and wizard links (#17822) 2022-08-10 00:13:42 +05:30
category-list.scss FIX: add category colors back to categories pages (#21977) 2023-06-07 12:57:10 -04:00
compose.scss REFACTOR: move shadow vars to css custom props (#22094) 2023-06-13 16:38:31 -04:00
discourse.scss UX: improve layout and styles for solo preferences (#21094) 2023-04-19 09:41:02 -04:00
edit-category.scss UX: Move category editing/creation to its own page (#10973) 2020-10-23 12:49:02 -04:00
group.scss UX: Fix alignment in group navigation bar (#15169) 2021-12-02 09:45:33 -05:00
header.scss DEV: Use more css vars (#18561) 2022-10-12 16:05:42 +02:00
history.scss DEV: Use css var font sizes (#18518) 2022-10-12 15:31:59 +02:00
latest-topic-list.scss DEV: Use css var font sizes (#18518) 2022-10-12 15:31:59 +02:00
login.scss CSS: Add background color to signin header (#22539) 2023-07-11 10:04:55 -05:00
menu-panel.scss UX: show tooltip for global nav section icon (#21974) 2023-06-08 12:57:44 -04:00
modal.scss FEATURE: support for chronologically merging posts into existing topic (#21374) 2023-05-25 14:38:34 -04:00
topic-list.scss UX: Fix positioning of mobile show-more following 71ff3417 (#23189) 2023-08-22 17:16:12 +01:00
topic-post.scss UX: Use pill design on both mobile and desktop (#23124) 2023-08-17 14:37:11 -03:00
topic.scss UX: Use pill design on both mobile and desktop (#23124) 2023-08-17 14:37:11 -03:00
upload.scss FEATURE: use native file picker in composer (#13552) 2021-06-30 12:45:47 +04:00
user.scss DEV: common CSS property for content backgrounds (#23467) 2023-09-08 12:07:04 -04:00