Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/docsearch-css/src/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
margin: 0 0 0 16px;
padding: 0 8px;
user-select: none;
min-width: 155px;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we know the value is 155px?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just inspected the element for the value:

CleanShot 2021-07-16 at 21 08 30@2x

Not a exact one, but it works in the webpack site case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The computed size of the component loaded is 155.359px, I assume that's where @chenxsan also found it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a different font, placeholder or zoom level is used? I guess it's still a safe default, but I think in some cases it will still flash

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think users could always customize it to their own use cases. We're just providing a default one which should hopefully eliminate the flash for most of the cases. For instance, the value would work for https://docusaurus.io/ as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a different font, placeholder or zoom level is used?

Most of these won't have effect unless the user is already overriding the provided styles. I think this could be a safe default and it is requested quite frequently.

wdyt? @Haroenv

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's safer with the min- change IMO.

But I agree with Haroen. I feel like setting the constraint on .DocSearch-Button-Keys is better because that's ultimately what we want as constant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@francoischalifour I don't think it would work on .DocSearch-Button-Keys considering it's controlled by a state value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, we can still move that check one line below to always render that element though?

Copy link
Copy Markdown
Contributor Author

@chenxsan chenxsan Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing up this as I found a problem with my solution.

Depending on the key state, we have two cases :

  1. a search box with the keys

CleanShot 2021-07-21 at 16 05 27@2x

  1. a search box without the keys

CleanShot 2021-07-21 at 16 05 07@2x

When there's no keys, the current solution would be deficient, as it results in a wide search box:
CleanShot 2021-07-21 at 16 10 17@2x

I'll see what I can do with it.

}

.DocSearch-Button:hover,
Expand Down Expand Up @@ -62,6 +63,10 @@
}

@media (max-width: 750px) {
.DocSearch-Button {
min-width: auto;
}

.DocSearch-Button-KeySeparator,
.DocSearch-Button-Key {
display: none;
Expand Down