discourse/app/assets/stylesheets/mobile
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
..
components DEV: FloatKit (#23312) 2023-09-12 15:06:51 +02:00
select-kit DEV: Use css var font sizes (#18518) 2022-10-12 15:31:59 +02:00
_index.scss FIX: add mobile specific stylesheet for onebox (#23329) 2023-08-31 10:35:28 +10:00
admin_badges.scss General admin style cleanup 2019-10-04 13:25:54 -04:00
admin_customize.scss DEV: Clean up some styles (#14374) 2021-09-20 09:52:03 -04:00
admin_report_counters.scss
admin_report_table.scss DEV: Use css var font sizes (#18518) 2022-10-12 15:31:59 +02:00
admin_report.scss
admin_reports.scss
alert.scss FEATURE: update bootstrap mode notice to add invite and wizard links (#17822) 2022-08-10 00:13:42 +05:30
buttons.scss
compose.scss FIX: Show tag chooser in composer for PM on mobile (#22241) 2023-06-26 20:12:32 +03:00
dashboard.scss DEV: Use css var font sizes (#18518) 2022-10-12 15:31:59 +02:00
directory.scss REFACTOR: user directories without <table>, second attempt (#20515) 2023-03-02 15:10:19 -05:00
discourse.scss UX: Make Sidebar more consistent with user menu on mobile (#17940) 2022-08-16 13:45:32 +08:00
edit-category.scss DEV: Use css var font sizes (#18518) 2022-10-12 15:31:59 +02:00
emoji.scss UX: Larger images in mobile emoji picker (#17013) 2022-06-07 12:00:09 -04:00
group.scss UX: style improvements to new user tables (#20530) 2023-03-06 09:30:48 -05:00
header.scss FIX: A mobile header regression in 9cc2b5c (#22344) 2023-06-29 10:36:27 +02:00
history.scss UX: improve edit history display (#21474) 2023-05-24 08:59:13 +08:00
lightbox.scss FEATURE: automatic dark mode (#10341) 2020-08-03 22:57:10 -04:00
login.scss UX: better email login pages (#19058) 2022-11-17 13:09:39 +05:30
menu-panel.scss UX: remove sidebar background color (#21775) 2023-06-06 09:24:56 -04:00
modal.scss UX: remove fixed width from buttons (#20369) 2023-02-20 11:17:17 +01:00
new-user.scss DEV: remove old and experimental user menu styles (#21326) 2023-05-02 15:07:42 -04:00
onebox.scss FIX: add mobile specific stylesheet for onebox (#23329) 2023-08-31 10:35:28 +10:00
personal-message.scss UX: refactor & update small post styles (#19274) 2022-12-05 09:54:29 -05:00
push-notifications-mobile.scss
reviewables.scss UX/DEV: Review queue redesign fixes (#20239) 2023-03-02 16:40:53 +01:00
search.scss UX: Fix topic status icon size in mobile search results (#15251) 2021-12-09 14:32:12 -05:00
tagging.scss FEATURE: ability to add description to tags (#15125) 2021-12-01 09:18:56 +11:00
topic-list.scss FEATURE: New topics vs replies toggle for the new new view (#22920) 2023-08-18 12:44:04 +08:00
topic-post.scss UX: Use pill design on both mobile and desktop (#23124) 2023-08-17 14:37:11 -03:00
topic.scss DEV: Use more css vars (#18561) 2022-10-12 16:05:42 +02:00
upload.scss FEATURE: use native file picker in composer (#13552) 2021-06-30 12:45:47 +04:00
user-badges.scss UX: Improve user profile header layout on mobile 2019-03-20 14:56:34 -04:00
user.scss UX: improve layout and styles for solo preferences (#21094) 2023-04-19 09:41:02 -04:00