|
2 | 2 |
|
3 | 3 | .c-search { |
4 | 4 | display: flex; |
| 5 | + justify-content: flex-end; |
| 6 | + |
| 7 | + &:focus-within { /* #1 */ |
| 8 | + outline: 5px auto blue; |
| 9 | + outline: 5px auto -webkit-focus-ring-color; |
| 10 | + } |
| 11 | +} |
| 12 | + |
| 13 | +.c-search-form { |
| 14 | + position-anchor: --my-anchor; |
| 15 | + inset: auto; |
| 16 | + right: anchor(left); |
| 17 | + align-self: anchor-center; |
| 18 | + width: 0; /* #2 */ |
| 19 | + height: anchor-size(height); /* #3 */ |
| 20 | + margin: 0; |
| 21 | + margin-inline-end: var(--uc3-space-base); |
| 22 | + padding: unset; |
| 23 | + transition-property: opacity, display, width, overlay; |
| 24 | + transition-duration: 0.3s; |
| 25 | + transition-behavior: allow-discrete; |
5 | 26 | border: 1px solid black; |
| 27 | + opacity: 0; /* #2 */ |
6 | 28 |
|
7 | 29 | input { |
8 | | - flex: 1 1 auto; |
9 | 30 | inline-size: 100%; |
10 | 31 | padding: 0.3rem 0.6rem; |
11 | | - border: none; |
| 32 | + border-style: none; |
12 | 33 | } |
13 | 34 |
|
14 | 35 | button { |
15 | 36 | padding-inline: 0.8rem; |
16 | | - border: none; |
| 37 | + border-style: none; |
17 | 38 | background-color: black; |
18 | 39 | color: white; |
| 40 | + |
| 41 | + &:focus { |
| 42 | + margin: 1px; |
| 43 | + background-color: white; |
| 44 | + color: black; |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + &:popover-open { |
| 49 | + display: flex; |
| 50 | + width: 45vw; |
| 51 | + opacity: 1; |
| 52 | + |
| 53 | + @starting-style { |
| 54 | + width: 0; |
| 55 | + opacity: 0; |
| 56 | + } |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +.c-search-toggle { |
| 61 | + anchor-name: --my-anchor; |
| 62 | + block-size: 1.9rem; |
| 63 | + inline-size: 1.9rem; |
| 64 | + padding: unset; |
| 65 | + border-style: none; |
| 66 | + background-color: var(--uc3-color-dark-blue); |
| 67 | + mask: url('data-url:npm:fa-solid/magnifying-glass.svg') center / contain; |
| 68 | +} |
| 69 | + |
| 70 | +@media (width > 45rem) { |
| 71 | + .c-search-form { |
| 72 | + &:popover-open { |
| 73 | + width: 35vw; |
| 74 | + |
| 75 | + @starting-style { /* #4, 5 */ |
| 76 | + width: 0; |
| 77 | + opacity: 0; |
| 78 | + } |
| 79 | + } |
19 | 80 | } |
20 | 81 | } |
| 82 | + |
| 83 | +/* |
| 84 | +#1: Search toggle loses it's focus ring with mask style, so reapply |
| 85 | +focus ring to the component container when toggle is focused. |
| 86 | +
|
| 87 | +#2: Final state of the exit animation. |
| 88 | +
|
| 89 | +#3: Set the popover height to that of the anchor (c-search-toggle). |
| 90 | +
|
| 91 | +#4: Starting state for the animiation. |
| 92 | +
|
| 93 | +#5: When using this media query, the starting styles before |
| 94 | +the query are reset for some reason, so duplicate them here. |
| 95 | +*/ |
0 commit comments