-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b01a07
commit 0909088
Showing
7 changed files
with
163 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import SearchBox from "./searchBox"; | ||
|
||
export default SearchBox; |
34 changes: 34 additions & 0 deletions
34
packages/blocky-example/src/components/searchBox/searchBox.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
.blocky-example-search-box { | ||
display: flex; | ||
height: 28px; | ||
background-color: var(--bg-color); | ||
position: absolute; | ||
top: 12px; | ||
right: 18px; | ||
padding: 4px 8px; | ||
border-radius: 4px; | ||
z-index: 10; | ||
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | ||
|
||
input { | ||
background-color: transparent; | ||
border: none; | ||
color: var(--primary-text-color); | ||
|
||
&:focus { | ||
outline: none; | ||
} | ||
} | ||
|
||
.result-display { | ||
padding: 0px 8px; | ||
line-height: 28px; | ||
font-size: 12px; | ||
color: var(--primary-text-color); | ||
} | ||
|
||
button { | ||
margin-left: 2px; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/blocky-example/src/components/searchBox/searchBox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Component, createRef, JSX } from "preact"; | ||
import Button from "@pkg/components/button"; | ||
import "./searchBox.scss"; | ||
|
||
export interface SearchBoxProps { | ||
onClose?: () => void; | ||
} | ||
|
||
class SearchBox extends Component<SearchBoxProps> { | ||
#inputRef = createRef<HTMLInputElement>(); | ||
|
||
override componentDidMount(): void { | ||
window.requestAnimationFrame(() => { | ||
this.#inputRef.current?.focus(); | ||
}); | ||
} | ||
|
||
#handleInputKeyDown = (e: JSX.TargetedKeyboardEvent<HTMLInputElement>) => { | ||
if (e.key === "Escape") { | ||
this.props.onClose?.(); | ||
} | ||
}; | ||
|
||
override render(props: SearchBoxProps) { | ||
return ( | ||
<div className="blocky-example-search-box"> | ||
<input | ||
placeholder="Find" | ||
onKeyDown={this.#handleInputKeyDown} | ||
ref={this.#inputRef} | ||
/> | ||
<div className="result-display">No results</div> | ||
<Button>{"<"}</Button> | ||
<Button>{">"}</Button> | ||
<Button onClick={props.onClose}>{"X"}</Button> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default SearchBox; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.