2021-10-06 23:42:52 +08:00
|
|
|
@mixin user-item-flex {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2022-10-12 22:05:42 +08:00
|
|
|
line-height: var(--line-height-medium);
|
2021-10-06 23:42:52 +08:00
|
|
|
color: var(--primary-high-or-secondary-low);
|
|
|
|
}
|
|
|
|
|
|
|
|
@mixin separator {
|
|
|
|
border-top: 1px solid var(--primary-low);
|
|
|
|
margin-top: 0.5em;
|
|
|
|
padding-top: 0.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
$search-pad-vertical: 0.25em;
|
|
|
|
$search-pad-horizontal: 0.5em;
|
|
|
|
|
2018-10-30 22:44:49 +08:00
|
|
|
.search-menu {
|
2020-08-11 04:17:15 +08:00
|
|
|
.menu-panel .panel-body-contents {
|
|
|
|
overflow-y: auto;
|
|
|
|
}
|
|
|
|
|
2018-10-30 22:44:49 +08:00
|
|
|
.search-input {
|
|
|
|
position: relative;
|
2021-10-19 01:17:27 +08:00
|
|
|
margin: 1px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
border: 1px solid var(--primary-medium);
|
2023-08-26 05:09:18 +08:00
|
|
|
border-radius: var(--d-border-radius-large);
|
DEV: FloatKit (#23650)
This PR introduces three new concepts to Discourse codebase through an addon called "FloatKit":
- menu
- tooltip
- toast
## Tooltips
### Component
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>
```
### Service
You can manually show a tooltip using the `tooltip` service:
```javascript
const tooltipInstance = await this.tooltip.show(
document.querySelector(".my-span"),
options
)
// and later manual 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
Menus are very similar to tooltips and provide the same kind of APIs:
### Component
```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>
```
### Service
You can manually show a menu using the `menu` service:
```javascript
const menuInstance = await this.menu.show(
document.querySelector(".my-span"),
options
)
// and later manual 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 }
}
)
```
## Toasts
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-26 19:39:52 +08:00
|
|
|
|
2021-10-19 01:17:27 +08:00
|
|
|
input#search-term {
|
|
|
|
border-width: 0;
|
2023-08-29 00:04:41 +08:00
|
|
|
border-radius: var(--d-border-radius-large);
|
2021-10-19 01:17:27 +08:00
|
|
|
margin-bottom: 0;
|
2021-10-19 08:01:08 +08:00
|
|
|
width: auto;
|
|
|
|
flex-grow: 1;
|
|
|
|
padding-right: 50px;
|
2021-10-19 01:17:27 +08:00
|
|
|
&:focus {
|
|
|
|
outline: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-20 01:01:42 +08:00
|
|
|
.btn.search-context {
|
2021-10-19 08:01:08 +08:00
|
|
|
margin: 2px;
|
2021-10-20 01:01:42 +08:00
|
|
|
margin-right: 0;
|
2023-01-18 22:40:56 +08:00
|
|
|
white-space: nowrap;
|
2021-10-19 01:17:27 +08:00
|
|
|
}
|
|
|
|
&:focus-within {
|
|
|
|
@include default-focus;
|
|
|
|
}
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.heading {
|
|
|
|
padding: 5px 0 5px 5px;
|
|
|
|
.filter {
|
|
|
|
padding: 0 5px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
input[type="text"] {
|
2021-10-19 01:17:27 +08:00
|
|
|
margin-right: 0px;
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.results {
|
|
|
|
display: flex;
|
2021-10-06 23:42:52 +08:00
|
|
|
flex-direction: column;
|
|
|
|
padding-top: $search-pad-vertical;
|
|
|
|
padding-bottom: $search-pad-vertical;
|
2018-10-30 22:44:49 +08:00
|
|
|
|
|
|
|
.list {
|
2019-03-04 17:30:09 +08:00
|
|
|
min-width: 100px;
|
|
|
|
|
2018-10-30 22:44:49 +08:00
|
|
|
.item {
|
|
|
|
.blurb {
|
|
|
|
// https://css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
word-wrap: break-word;
|
|
|
|
word-break: break-all;
|
|
|
|
word-break: break-word;
|
|
|
|
-webkit-hyphens: auto;
|
|
|
|
hyphens: auto;
|
2019-06-28 17:14:38 +08:00
|
|
|
margin-top: 0.25em;
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-02 17:26:43 +08:00
|
|
|
.search-result-topic {
|
2021-06-08 03:26:22 +08:00
|
|
|
.first-line {
|
|
|
|
display: block;
|
2022-10-12 22:05:42 +08:00
|
|
|
line-height: var(--line-height-medium);
|
2021-06-08 03:26:22 +08:00
|
|
|
}
|
|
|
|
|
2019-07-02 17:26:43 +08:00
|
|
|
.second-line {
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
2021-10-06 23:42:52 +08:00
|
|
|
align-items: baseline;
|
|
|
|
|
|
|
|
.badge-wrapper {
|
|
|
|
margin-right: 0.5em;
|
|
|
|
}
|
|
|
|
.discourse-tags .discourse-tag {
|
2023-04-05 05:26:06 +08:00
|
|
|
margin-right: 0.35em;
|
2019-07-02 17:26:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-03 12:14:24 +08:00
|
|
|
.search-result-post {
|
|
|
|
.blurb {
|
|
|
|
font-size: var(--font-down-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.search-result-category {
|
|
|
|
.widget-link {
|
|
|
|
margin-bottom: 0;
|
2018-12-07 08:22:04 +08:00
|
|
|
}
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.search-result-group .group-result,
|
|
|
|
.search-result-user .user-result {
|
2018-10-30 22:44:49 +08:00
|
|
|
display: flex;
|
2021-10-06 23:42:52 +08:00
|
|
|
align-items: center;
|
|
|
|
font-size: var(--font-down-1);
|
|
|
|
}
|
|
|
|
.search-result-group .group-result {
|
|
|
|
.d-icon,
|
|
|
|
.avatar-flair {
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
|
|
|
|
2021-10-13 18:38:35 +08:00
|
|
|
.avatar-flair,
|
|
|
|
.d-icon-users {
|
2021-10-06 23:42:52 +08:00
|
|
|
margin-right: 0.5em;
|
2021-10-13 18:38:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.avatar-flair {
|
2021-10-06 23:42:52 +08:00
|
|
|
border-radius: 50%;
|
|
|
|
&.avatar-flair-image {
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
background-size: 100% 100%;
|
2019-03-08 16:23:44 +08:00
|
|
|
}
|
2021-10-06 23:42:52 +08:00
|
|
|
.d-icon {
|
|
|
|
margin-right: 0;
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.group-names {
|
|
|
|
@include user-item-flex;
|
|
|
|
.name,
|
|
|
|
.slug {
|
|
|
|
@include ellipsis;
|
|
|
|
}
|
2019-03-04 17:30:09 +08:00
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.name {
|
|
|
|
font-weight: 700;
|
2019-03-04 17:30:09 +08:00
|
|
|
}
|
2021-10-06 23:42:52 +08:00
|
|
|
}
|
|
|
|
}
|
2019-03-04 17:30:09 +08:00
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.search-result-user .user-result {
|
|
|
|
.user-titles {
|
|
|
|
@include user-item-flex;
|
2019-03-08 16:23:44 +08:00
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.username,
|
|
|
|
.name {
|
|
|
|
@include ellipsis;
|
|
|
|
}
|
2019-03-08 16:23:44 +08:00
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.name {
|
|
|
|
font-weight: 700;
|
|
|
|
}
|
2019-03-04 17:30:09 +08:00
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.username,
|
|
|
|
.name,
|
|
|
|
.custom-field {
|
|
|
|
color: var(--primary-high-or-secondary-low);
|
|
|
|
}
|
2019-03-08 16:23:44 +08:00
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.custom-field {
|
|
|
|
font-size: var(--font-down-2);
|
2019-03-08 16:23:44 +08:00
|
|
|
}
|
|
|
|
}
|
2021-10-06 23:42:52 +08:00
|
|
|
}
|
2019-03-08 16:23:44 +08:00
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.search-result-category,
|
|
|
|
.search-result-tag {
|
|
|
|
+ .search-result-user,
|
|
|
|
+ .search-result-group {
|
|
|
|
@include separator;
|
2019-03-04 17:30:09 +08:00
|
|
|
}
|
2021-10-06 23:42:52 +08:00
|
|
|
}
|
2019-03-04 17:30:09 +08:00
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.search-result-user .user-result img.avatar,
|
|
|
|
.search-item-user img.avatar {
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
2023-01-18 22:40:38 +08:00
|
|
|
margin-right: 0.5em;
|
2021-10-06 23:42:52 +08:00
|
|
|
}
|
2018-10-30 22:44:49 +08:00
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.label-suffix {
|
|
|
|
color: var(--primary-medium);
|
2023-01-18 22:40:38 +08:00
|
|
|
margin-right: 0.33em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.search-item-tag {
|
|
|
|
color: var(--primary-high);
|
2021-10-06 23:42:52 +08:00
|
|
|
}
|
2018-10-30 22:44:49 +08:00
|
|
|
|
2021-10-14 00:09:28 +08:00
|
|
|
.extra-hint {
|
|
|
|
color: var(--primary-low-mid);
|
|
|
|
font-size: var(--font-down-1);
|
|
|
|
}
|
|
|
|
|
2023-01-12 03:02:22 +08:00
|
|
|
.search-item-slug {
|
2023-01-20 21:40:48 +08:00
|
|
|
.keyword {
|
|
|
|
margin-right: 0.33em;
|
|
|
|
}
|
2023-01-12 03:02:22 +08:00
|
|
|
.badge-wrapper {
|
|
|
|
font-size: var(--font-0);
|
|
|
|
margin-left: 2px;
|
|
|
|
}
|
2021-10-06 23:42:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.search-menu-initial-options {
|
|
|
|
+ .search-result-tag,
|
|
|
|
+ .search-result-category,
|
|
|
|
+ .search-result-user,
|
|
|
|
+ .search-result-group {
|
|
|
|
@include separator;
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
|
|
|
}
|
2021-07-16 23:08:20 +08:00
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.search-menu-initial-options,
|
|
|
|
.search-result-tag,
|
2021-07-16 23:08:20 +08:00
|
|
|
.search-menu-assistant {
|
2023-01-12 03:02:22 +08:00
|
|
|
.search-item-prefix {
|
2023-01-18 22:40:38 +08:00
|
|
|
margin-right: 0.33em;
|
|
|
|
}
|
|
|
|
.badge-wrapper {
|
|
|
|
font-size: var(--font-0);
|
|
|
|
margin-right: 0.5em;
|
2023-01-12 03:02:22 +08:00
|
|
|
}
|
2021-10-06 23:42:52 +08:00
|
|
|
.search-link {
|
2023-01-12 03:02:22 +08:00
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
2023-01-18 22:40:38 +08:00
|
|
|
align-items: baseline;
|
2021-11-26 04:44:15 +08:00
|
|
|
@include ellipsis;
|
2021-10-06 23:42:52 +08:00
|
|
|
.d-icon {
|
2023-01-18 22:40:38 +08:00
|
|
|
margin-right: 0.33em;
|
2021-10-06 23:42:52 +08:00
|
|
|
vertical-align: middle;
|
|
|
|
}
|
|
|
|
.d-icon-tag {
|
|
|
|
font-size: var(--font-down-2);
|
2021-07-16 23:08:20 +08:00
|
|
|
}
|
2021-08-19 02:14:10 +08:00
|
|
|
|
2021-10-06 23:42:52 +08:00
|
|
|
.d-icon-search {
|
|
|
|
font-size: var(--font-down-1);
|
|
|
|
}
|
2021-08-19 02:14:10 +08:00
|
|
|
}
|
2021-10-06 23:42:52 +08:00
|
|
|
}
|
2021-11-23 13:11:17 +08:00
|
|
|
}
|
2021-08-19 02:14:10 +08:00
|
|
|
|
2021-11-23 13:11:17 +08:00
|
|
|
.browser-search-tip,
|
|
|
|
.search-random-quick-tip {
|
2021-11-26 04:44:15 +08:00
|
|
|
padding: $search-pad-vertical 1px;
|
2021-11-23 13:11:17 +08:00
|
|
|
font-size: var(--font-down-2);
|
|
|
|
color: var(--primary-medium);
|
|
|
|
.tip-label {
|
|
|
|
background-color: rgba(var(--tertiary-rgb), 0.1);
|
|
|
|
margin-right: 4px;
|
|
|
|
padding: 2px 4px;
|
|
|
|
display: inline-block;
|
|
|
|
&.tip-clickable {
|
|
|
|
cursor: pointer;
|
2021-08-19 02:14:10 +08:00
|
|
|
}
|
2021-07-16 23:08:20 +08:00
|
|
|
}
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
|
|
|
|
2021-11-26 04:44:15 +08:00
|
|
|
.search-menu-recent {
|
|
|
|
@include separator;
|
|
|
|
|
|
|
|
.heading {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
h4 {
|
|
|
|
color: var(--primary-medium);
|
|
|
|
font-weight: normal;
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
.clear-recent-searches {
|
|
|
|
cursor: pointer;
|
|
|
|
color: var(--primary-low-mid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-23 13:11:17 +08:00
|
|
|
.browser-search-tip {
|
|
|
|
padding-top: 0.5em;
|
|
|
|
}
|
|
|
|
|
2018-10-30 22:44:49 +08:00
|
|
|
.searching {
|
|
|
|
position: absolute;
|
2021-10-19 01:17:27 +08:00
|
|
|
top: $search-pad-vertical + 0.2em;
|
2021-10-06 23:42:52 +08:00
|
|
|
right: $search-pad-horizontal;
|
|
|
|
min-height: 20px;
|
2018-10-30 22:44:49 +08:00
|
|
|
|
|
|
|
.spinner {
|
2021-10-06 23:42:52 +08:00
|
|
|
width: 12px;
|
|
|
|
height: 12px;
|
2018-10-30 22:44:49 +08:00
|
|
|
border-width: 2px;
|
|
|
|
margin: 0;
|
2021-10-06 23:42:52 +08:00
|
|
|
margin-top: 2px;
|
|
|
|
}
|
|
|
|
|
|
|
|
a.show-advanced-search,
|
|
|
|
a.clear-search {
|
|
|
|
padding: 0px 3px;
|
|
|
|
display: inline-block;
|
|
|
|
background-color: transparent;
|
|
|
|
.d-icon {
|
|
|
|
color: var(--primary-low-mid);
|
|
|
|
}
|
2023-09-14 05:24:36 +08:00
|
|
|
&:focus,
|
|
|
|
&:hover {
|
|
|
|
.d-icon {
|
|
|
|
color: var(--primary-high);
|
|
|
|
}
|
2021-10-06 23:42:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
a.clear-search {
|
|
|
|
margin-right: 3px;
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.no-results {
|
2021-10-06 23:42:52 +08:00
|
|
|
padding: $search-pad-vertical $search-pad-horizontal;
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.search-link {
|
2021-10-06 23:42:52 +08:00
|
|
|
display: block;
|
|
|
|
padding: $search-pad-vertical $search-pad-horizontal;
|
|
|
|
|
|
|
|
// This is purposefully redundant
|
|
|
|
// the search widget can be used outside of the header
|
|
|
|
// and the focus/hover styles from the header in those cases wouldn't follow
|
|
|
|
&:focus,
|
|
|
|
&:hover {
|
2023-02-21 17:15:49 +08:00
|
|
|
background-color: var(--highlight-bg);
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
|
|
|
|
2018-11-06 23:00:53 +08:00
|
|
|
.topic {
|
2021-06-08 03:26:22 +08:00
|
|
|
display: block;
|
2018-11-06 23:00:53 +08:00
|
|
|
}
|
|
|
|
|
2018-10-30 22:44:49 +08:00
|
|
|
.topic-title {
|
2021-06-04 10:54:22 +08:00
|
|
|
color: var(--tertiary);
|
2020-04-01 08:55:11 +08:00
|
|
|
overflow-wrap: anywhere;
|
2020-04-01 09:57:09 +08:00
|
|
|
@supports not (overflow-wrap: anywhere) {
|
|
|
|
word-break: break-word;
|
|
|
|
}
|
2018-10-30 22:44:49 +08:00
|
|
|
margin-right: 0.25em;
|
|
|
|
}
|
|
|
|
}
|
2021-10-06 23:42:52 +08:00
|
|
|
.search-result-topic,
|
|
|
|
.search-result-post {
|
|
|
|
.search-link {
|
|
|
|
padding: 0.5em;
|
|
|
|
}
|
|
|
|
}
|
2018-10-30 22:44:49 +08:00
|
|
|
}
|
2023-08-22 06:51:11 +08:00
|
|
|
|
|
|
|
// these styles will become the default once the glimmer search menu
|
|
|
|
// is enabled for all users, and the old search menu is removed
|
|
|
|
// we can then drop any '!important' rules
|
|
|
|
.search-menu.glimmer-search-menu {
|
|
|
|
.search-item-tag .d-icon {
|
|
|
|
margin-right: 0 !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.search-item-user {
|
|
|
|
.username {
|
|
|
|
margin-right: 0.33rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
img.avatar {
|
|
|
|
margin-right: 0 !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|