discourse/app/assets/stylesheets/common/base/search-menu.scss

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

398 lines
7.6 KiB
SCSS
Raw Normal View History

@mixin user-item-flex {
display: flex;
flex-direction: column;
line-height: var(--line-height-medium);
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;
.search-menu,
.search-menu-container {
.menu-panel .panel-body-contents {
overflow-y: auto;
}
.search-input {
position: relative;
display: flex;
align-items: center;
background: var(--secondary-very-high);
border-radius: var(--d-input-border-radius);
margin: 1px;
padding: 0.25rem;
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
input#search-term {
background: none;
border: 0;
margin-bottom: 0;
width: auto;
flex-grow: 1;
padding-right: 50px;
&:focus {
outline: none;
}
}
.btn.search-context {
margin: 2px;
margin-right: 0;
white-space: nowrap;
background-color: var(--primary-300);
&:hover {
background-color: var(--primary-medium);
}
}
&:focus-within {
@include default-focus;
}
}
.heading {
padding: 5px 0 5px 5px;
.filter {
padding: 0 5px;
}
}
.menu-panel {
border: 0;
box-shadow: var(--shadow-dropdown);
padding: 1rem;
}
&.menu-panel-results {
position: relative;
.menu-panel {
position: absolute;
left: 0;
right: 0;
top: unset;
width: unset;
}
}
.results {
display: flex;
flex-direction: column;
padding-top: $search-pad-vertical;
.list {
min-width: 100px;
.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;
margin-top: 0.25em;
}
}
}
.search-result-topic {
.first-line {
display: block;
line-height: var(--line-height-medium);
}
.second-line {
display: flex;
flex-wrap: wrap;
align-items: baseline;
gap: 0 0.5em;
}
}
.search-result-post {
.blurb {
font-size: var(--font-down-1);
}
}
.search-result-category {
.widget-link {
margin-bottom: 0;
}
}
.search-result-group .group-result,
.search-result-user .user-result {
display: flex;
align-items: center;
font-size: var(--font-down-1);
}
.search-result-group .group-result {
.d-icon,
.avatar-flair {
width: 20px;
height: 20px;
}
.avatar-flair,
.d-icon-users {
margin-right: 0.5em;
}
.avatar-flair {
border-radius: 50%;
&.avatar-flair-image {
background-repeat: no-repeat;
background-size: 100% 100%;
}
.d-icon {
margin-right: 0;
}
}
.group-names {
@include user-item-flex;
.name,
.slug {
@include ellipsis;
}
.name {
font-weight: 700;
}
}
}
.search-result-user .user-result {
.user-titles {
@include user-item-flex;
.username,
.name {
@include ellipsis;
}
.name {
font-weight: 700;
}
.username,
.name,
.custom-field {
color: var(--primary-high-or-secondary-low);
}
.custom-field {
font-size: var(--font-down-2);
}
}
}
.search-result-category,
.search-result-tag {
+ .search-result-user,
+ .search-result-group {
@include separator;
}
}
.search-result-user .user-result img.avatar,
.search-item-user img.avatar {
width: 20px;
height: 20px;
margin-right: 0.5em;
}
.label-suffix {
color: var(--primary-medium);
margin-right: 0.33em;
}
.search-item-tag {
color: var(--primary-high);
}
.extra-hint {
color: var(--primary-low-mid);
font-size: var(--font-down-1);
}
DEV: Add search suggestions for tag-intersections (#19777) Added `tagIntersection` search context for handling search suggestions on tag intersection and tag+category routes. # Tag & Category Route Search Suggestions eg. /tags/c/general/5/updates ### Before <img width="422" alt="Screenshot 2023-01-06 at 2 58 50 PM" src="https://user-images.githubusercontent.com/50783505/211098933-ade438c6-5008-49ce-9a90-c8200ec5fe00.png"> ### After <img width="359" alt="Screenshot 2023-01-06 at 3 00 35 PM" src="https://user-images.githubusercontent.com/50783505/211099183-c3feaeac-8661-47ed-843c-da9d9fb78e9e.png"> # Tag Intersection Route Search Suggestions eg. /tags/intersection/updates/foo ### Before <img width="421" alt="Screenshot 2023-01-06 at 3 02 23 PM" src="https://user-images.githubusercontent.com/50783505/211099435-e8fc6d87-2772-45b5-b455-1831f80eab3a.png"> ### After <img width="362" alt="Screenshot 2023-01-09 at 2 02 09 PM" src="https://user-images.githubusercontent.com/50783505/211397349-acb350f7-8e6a-4d9f-a749-8292e49400d9.png"> I defaulted to using `+` as a separator for tag intersections. The reasoning behind this is that we don't make the tag intersection routes easily accessible, so if you are going out of your way to view multiple tags, you are most likely going to be searching by **both** of those tags as well. # General Search Introducing flex wrap removes whitespace causing a [test](https://github.com/discourse/discourse/pull/19777/files#diff-5d3d13fabc1a511635eb7471ffe74f4d455d77f6984543c2be6ad136dfaa6d3aR813) to fail, but to remedy this I added spacing to the `.search-item-prefix` and `.search-item-slug` which achieves the same thing. ### After <img width="359" alt="Screenshot 2023-01-09 at 2 04 54 PM" src="https://user-images.githubusercontent.com/50783505/211397900-60220394-5596-4e13-afd0-b6130afa0de2.png">
2023-01-12 03:02:22 +08:00
.search-item-slug {
.keyword {
margin-right: 0.33em;
}
DEV: Add search suggestions for tag-intersections (#19777) Added `tagIntersection` search context for handling search suggestions on tag intersection and tag+category routes. # Tag & Category Route Search Suggestions eg. /tags/c/general/5/updates ### Before <img width="422" alt="Screenshot 2023-01-06 at 2 58 50 PM" src="https://user-images.githubusercontent.com/50783505/211098933-ade438c6-5008-49ce-9a90-c8200ec5fe00.png"> ### After <img width="359" alt="Screenshot 2023-01-06 at 3 00 35 PM" src="https://user-images.githubusercontent.com/50783505/211099183-c3feaeac-8661-47ed-843c-da9d9fb78e9e.png"> # Tag Intersection Route Search Suggestions eg. /tags/intersection/updates/foo ### Before <img width="421" alt="Screenshot 2023-01-06 at 3 02 23 PM" src="https://user-images.githubusercontent.com/50783505/211099435-e8fc6d87-2772-45b5-b455-1831f80eab3a.png"> ### After <img width="362" alt="Screenshot 2023-01-09 at 2 02 09 PM" src="https://user-images.githubusercontent.com/50783505/211397349-acb350f7-8e6a-4d9f-a749-8292e49400d9.png"> I defaulted to using `+` as a separator for tag intersections. The reasoning behind this is that we don't make the tag intersection routes easily accessible, so if you are going out of your way to view multiple tags, you are most likely going to be searching by **both** of those tags as well. # General Search Introducing flex wrap removes whitespace causing a [test](https://github.com/discourse/discourse/pull/19777/files#diff-5d3d13fabc1a511635eb7471ffe74f4d455d77f6984543c2be6ad136dfaa6d3aR813) to fail, but to remedy this I added spacing to the `.search-item-prefix` and `.search-item-slug` which achieves the same thing. ### After <img width="359" alt="Screenshot 2023-01-09 at 2 04 54 PM" src="https://user-images.githubusercontent.com/50783505/211397900-60220394-5596-4e13-afd0-b6130afa0de2.png">
2023-01-12 03:02:22 +08:00
.badge-wrapper {
font-size: var(--font-0);
margin-left: 2px;
}
}
.search-menu-initial-options {
+ .search-result-tag,
+ .search-result-category,
+ .search-result-user,
+ .search-result-group {
@include separator;
}
}
.search-menu-initial-options,
.search-result-tag,
.search-menu-assistant {
DEV: Add search suggestions for tag-intersections (#19777) Added `tagIntersection` search context for handling search suggestions on tag intersection and tag+category routes. # Tag & Category Route Search Suggestions eg. /tags/c/general/5/updates ### Before <img width="422" alt="Screenshot 2023-01-06 at 2 58 50 PM" src="https://user-images.githubusercontent.com/50783505/211098933-ade438c6-5008-49ce-9a90-c8200ec5fe00.png"> ### After <img width="359" alt="Screenshot 2023-01-06 at 3 00 35 PM" src="https://user-images.githubusercontent.com/50783505/211099183-c3feaeac-8661-47ed-843c-da9d9fb78e9e.png"> # Tag Intersection Route Search Suggestions eg. /tags/intersection/updates/foo ### Before <img width="421" alt="Screenshot 2023-01-06 at 3 02 23 PM" src="https://user-images.githubusercontent.com/50783505/211099435-e8fc6d87-2772-45b5-b455-1831f80eab3a.png"> ### After <img width="362" alt="Screenshot 2023-01-09 at 2 02 09 PM" src="https://user-images.githubusercontent.com/50783505/211397349-acb350f7-8e6a-4d9f-a749-8292e49400d9.png"> I defaulted to using `+` as a separator for tag intersections. The reasoning behind this is that we don't make the tag intersection routes easily accessible, so if you are going out of your way to view multiple tags, you are most likely going to be searching by **both** of those tags as well. # General Search Introducing flex wrap removes whitespace causing a [test](https://github.com/discourse/discourse/pull/19777/files#diff-5d3d13fabc1a511635eb7471ffe74f4d455d77f6984543c2be6ad136dfaa6d3aR813) to fail, but to remedy this I added spacing to the `.search-item-prefix` and `.search-item-slug` which achieves the same thing. ### After <img width="359" alt="Screenshot 2023-01-09 at 2 04 54 PM" src="https://user-images.githubusercontent.com/50783505/211397900-60220394-5596-4e13-afd0-b6130afa0de2.png">
2023-01-12 03:02:22 +08:00
.search-item-prefix {
margin-right: 0.33em;
}
.badge-category__wrapper {
font-size: var(--font-0);
DEV: Add search suggestions for tag-intersections (#19777) Added `tagIntersection` search context for handling search suggestions on tag intersection and tag+category routes. # Tag & Category Route Search Suggestions eg. /tags/c/general/5/updates ### Before <img width="422" alt="Screenshot 2023-01-06 at 2 58 50 PM" src="https://user-images.githubusercontent.com/50783505/211098933-ade438c6-5008-49ce-9a90-c8200ec5fe00.png"> ### After <img width="359" alt="Screenshot 2023-01-06 at 3 00 35 PM" src="https://user-images.githubusercontent.com/50783505/211099183-c3feaeac-8661-47ed-843c-da9d9fb78e9e.png"> # Tag Intersection Route Search Suggestions eg. /tags/intersection/updates/foo ### Before <img width="421" alt="Screenshot 2023-01-06 at 3 02 23 PM" src="https://user-images.githubusercontent.com/50783505/211099435-e8fc6d87-2772-45b5-b455-1831f80eab3a.png"> ### After <img width="362" alt="Screenshot 2023-01-09 at 2 02 09 PM" src="https://user-images.githubusercontent.com/50783505/211397349-acb350f7-8e6a-4d9f-a749-8292e49400d9.png"> I defaulted to using `+` as a separator for tag intersections. The reasoning behind this is that we don't make the tag intersection routes easily accessible, so if you are going out of your way to view multiple tags, you are most likely going to be searching by **both** of those tags as well. # General Search Introducing flex wrap removes whitespace causing a [test](https://github.com/discourse/discourse/pull/19777/files#diff-5d3d13fabc1a511635eb7471ffe74f4d455d77f6984543c2be6ad136dfaa6d3aR813) to fail, but to remedy this I added spacing to the `.search-item-prefix` and `.search-item-slug` which achieves the same thing. ### After <img width="359" alt="Screenshot 2023-01-09 at 2 04 54 PM" src="https://user-images.githubusercontent.com/50783505/211397900-60220394-5596-4e13-afd0-b6130afa0de2.png">
2023-01-12 03:02:22 +08:00
}
.search-link {
DEV: Add search suggestions for tag-intersections (#19777) Added `tagIntersection` search context for handling search suggestions on tag intersection and tag+category routes. # Tag & Category Route Search Suggestions eg. /tags/c/general/5/updates ### Before <img width="422" alt="Screenshot 2023-01-06 at 2 58 50 PM" src="https://user-images.githubusercontent.com/50783505/211098933-ade438c6-5008-49ce-9a90-c8200ec5fe00.png"> ### After <img width="359" alt="Screenshot 2023-01-06 at 3 00 35 PM" src="https://user-images.githubusercontent.com/50783505/211099183-c3feaeac-8661-47ed-843c-da9d9fb78e9e.png"> # Tag Intersection Route Search Suggestions eg. /tags/intersection/updates/foo ### Before <img width="421" alt="Screenshot 2023-01-06 at 3 02 23 PM" src="https://user-images.githubusercontent.com/50783505/211099435-e8fc6d87-2772-45b5-b455-1831f80eab3a.png"> ### After <img width="362" alt="Screenshot 2023-01-09 at 2 02 09 PM" src="https://user-images.githubusercontent.com/50783505/211397349-acb350f7-8e6a-4d9f-a749-8292e49400d9.png"> I defaulted to using `+` as a separator for tag intersections. The reasoning behind this is that we don't make the tag intersection routes easily accessible, so if you are going out of your way to view multiple tags, you are most likely going to be searching by **both** of those tags as well. # General Search Introducing flex wrap removes whitespace causing a [test](https://github.com/discourse/discourse/pull/19777/files#diff-5d3d13fabc1a511635eb7471ffe74f4d455d77f6984543c2be6ad136dfaa6d3aR813) to fail, but to remedy this I added spacing to the `.search-item-prefix` and `.search-item-slug` which achieves the same thing. ### After <img width="359" alt="Screenshot 2023-01-09 at 2 04 54 PM" src="https://user-images.githubusercontent.com/50783505/211397900-60220394-5596-4e13-afd0-b6130afa0de2.png">
2023-01-12 03:02:22 +08:00
display: flex;
flex-wrap: wrap;
align-items: baseline;
@include ellipsis;
.d-icon {
margin-right: 0.33em;
vertical-align: middle;
}
.d-icon-tag {
font-size: var(--font-down-2);
}
.d-icon-search {
font-size: var(--font-down-1);
}
}
}
}
.browser-search-tip,
.search-random-quick-tip {
padding: $search-pad-vertical 1px;
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;
}
}
}
.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);
}
}
}
.browser-search-tip {
padding-top: 0.5em;
}
.searching {
.spinner {
width: 12px;
height: 12px;
border-width: 2px;
margin: 0;
margin-top: 2px;
}
a.show-advanced-search,
a.clear-search {
padding: 0px 3px;
display: inline-block;
background-color: transparent;
.d-icon {
color: var(--primary-medium);
}
&:focus,
&:hover {
.d-icon {
color: var(--primary-high);
}
}
}
a.clear-search {
margin-right: 3px;
}
}
.no-results {
padding: $search-pad-vertical $search-pad-horizontal;
}
.search-link {
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 {
background-color: var(--highlight-bg);
}
.topic {
display: block;
}
.topic-title {
color: var(--tertiary);
overflow-wrap: anywhere;
2020-04-01 09:57:09 +08:00
@supports not (overflow-wrap: anywhere) {
word-break: break-word;
}
margin-right: 0.25em;
}
}
.search-result-topic,
.search-result-post {
.search-link {
padding: 0.5em;
}
}
}
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;
}
}
}