-
Notifications
You must be signed in to change notification settings - Fork 1
Encapsulate state #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Encapsulate state #253
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
dc00201
Encapsulate state
dwjohnston 43f3c9c
More content
dwjohnston f997cc4
More content
dwjohnston e817a86
Update post
dwjohnston a60e804
Update example.
dwjohnston 1ed3511
Apply suggestions from code review
dwjohnston 22592b9
Update posts
dwjohnston b442eeb
Updates.
dwjohnston e0fc14f
Update auto complete.
dwjohnston fb995a2
Move to posts.
dwjohnston 0fcab80
Update src/app/layout.tsx
dwjohnston 9bc8837
Remove the manually coded components.
dwjohnston 7bb9874
Css fixes.
dwjohnston 1cedcf5
Typos
dwjohnston d2b5918
Try +https
dwjohnston d375530
empty commit
dwjohnston 9a274fc
Update post
dwjohnston fc4b4cd
Update date.
dwjohnston 30e60bf
Add tags, screenshot
dwjohnston af1bd9e
Update src/demos/encapsulate-state/AutocompleteDemo.tsx
dwjohnston eaf796d
Improve comment.
dwjohnston 51e26ac
Ugh. bs MDX problem.
dwjohnston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| SHOW_TEST_PAGES=true | ||
| SHOW_DRAFT_PAGES=true | ||
| SHOW_DRAFT_PAGES=true | ||
| GITHUB_TOKEN=${GITHUB_TOKEN_READONLY} | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -57,6 +57,10 @@ body { | |
| --column-width: 1100px; | ||
| } | ||
|
|
||
| img { | ||
| max-width: 100%; | ||
| } | ||
|
|
||
| pre, | ||
| pre:hover { | ||
| white-space: pre-wrap; | ||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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,91 @@ | ||
|
|
||
| "use client"; | ||
| import { AutocompleteB } from "@blacksheepcode/example-react-autocomplete"; | ||
|
|
||
|
|
||
| type TestItem = { | ||
| id: number; | ||
| name: string; | ||
| description: string; | ||
| }; | ||
|
|
||
| const mockItems: TestItem[] = [ | ||
| { id: 1, name: 'Apple', description: 'A red fruit' }, | ||
| { id: 2, name: 'Banana', description: 'A yellow fruit' }, | ||
| { id: 3, name: 'Cherry', description: 'A small red fruit' }, | ||
| { id: 4, name: 'Dragonfruit', description: 'A vibrant exotic fruit with a speckled interior' }, | ||
| { id: 5, name: 'Elderberry', description: 'Small dark berries often used in syrups' }, | ||
| { id: 6, name: 'Fig', description: 'A sweet, soft fruit with many seeds' }, | ||
| { id: 7, name: 'Grape', description: 'Small round fruit used for snacking and wine' }, | ||
| { id: 8, name: 'Honeydew', description: 'A sweet, pale green melon' }, | ||
| { id: 9, name: 'Indian Fig', description: 'Also known as prickly pear, a desert fruit' }, | ||
| { id: 10, name: 'Jackfruit', description: 'A large tropical fruit with sweet flesh' }, | ||
| { id: 11, name: 'Kiwi', description: 'A small fruit with fuzzy skin and bright green flesh' }, | ||
| { id: 12, name: 'Lemon', description: 'A tart yellow citrus fruit' }, | ||
| { id: 13, name: 'Mango', description: 'A juicy tropical stone fruit' }, | ||
| { id: 14, name: 'Nectarine', description: 'A smooth-skinned variety of peach' }, | ||
| { id: 15, name: 'Orange', description: 'A sweet citrus fruit' }, | ||
| { id: 16, name: 'Papaya', description: 'A soft, tropical fruit with orange flesh' }, | ||
| { id: 17, name: 'Quince', description: 'A yellow fruit often cooked into jams' }, | ||
| { id: 18, name: 'Raspberry', description: 'A small red berry with a tart-sweet flavor' }, | ||
| { id: 19, name: 'Strawberry', description: 'A popular red berry with a sweet taste' }, | ||
| { id: 20, name: 'Tomato', description: 'Botanically a fruit commonly used as a vegetable' }, | ||
| { id: 21, name: 'Ugli Fruit', description: 'A tangy citrus hybrid with rough skin' }, | ||
| { id: 22, name: 'Vanilla', description: 'A fragrant pod used for flavoring (technically an orchid fruit)' }, | ||
| { id: 23, name: 'Watermelon', description: 'A large, juicy melon with green rind and red flesh' }, | ||
| { id: 24, name: 'Xigua', description: 'Another name for watermelon, used in some regions' }, | ||
| { id: 25, name: 'Yuzu', description: 'A tart citrus used in Japanese cuisine' }, | ||
| { id: 26, name: 'Zucchini', description: 'A summer squash often treated as a vegetable' }, | ||
| { id: 27, name: 'Pineapple', description: 'A tropical fruit with sweet, juicy flesh and spiky skin' }, | ||
| { id: 28, name: 'Crabapple', description: 'A small tart apple often used for jams and preserves' }, | ||
| { id: 29, name: 'Apple Cider', description: 'A beverage made from pressed apples, often enjoyed warm or spiced' }, | ||
| { id: 30, name: 'Black Cherry', description: 'A dark-sweet cherry variety' }, | ||
| { id: 31, name: 'Maraschino Cherry', description: 'A preserved, sweet, bright red cherry used for desserts and cocktails' }, | ||
| { id: 32, name: 'Sour Cherry', description: 'A tart cherry commonly used in baking and preserves' }, | ||
| { id: 33, name: 'Concord Grape', description: 'A dark purple grape used for juice and jelly' }, | ||
| { id: 34, name: 'Grape Jelly', description: 'A sweet spread made from grapes' }, | ||
| { id: 35, name: 'Grapefruit', description: 'A large citrus fruit with a tangy, slightly bitter flavor' }, | ||
| ]; | ||
|
|
||
|
|
||
| const searchFn = async (searchTerm: string, pageNumber: number) => { | ||
| await new Promise(resolve => setTimeout(resolve, 300)); | ||
|
|
||
| if (!searchTerm) { | ||
|
|
||
| return { | ||
| items: [], | ||
| pageMeta: { | ||
| totalResults: 0, | ||
| pageNumber: 1, | ||
| resultsPerPage: 10, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| const filteredItems = mockItems.filter(item => | ||
| (`${item.name} ${item.description}`).toLowerCase().includes(searchTerm.toLowerCase()) | ||
| ); | ||
|
|
||
| return { | ||
| items: filteredItems, | ||
| pageMeta: { | ||
| totalResults: filteredItems.length, | ||
| pageNumber: pageNumber, | ||
| resultsPerPage: 10, | ||
| }, | ||
| }; | ||
| } | ||
| export function AutocompleteDemo() { | ||
| return ( | ||
| <div> | ||
| <AutocompleteB | ||
| searchFn={searchFn} | ||
| renderItem={(item) => <div>{item.name} - {item.description}</div>} | ||
| itemKey="id" | ||
| selectedValueDisplayStringFn={(item) => item.name} | ||
|
|
||
| /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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,9 @@ | ||
| "use client"; | ||
| import { SpecialButton2 } from "@blacksheepcode/example-react-autocomplete"; | ||
|
|
||
| export function SpecialButtonDemo() { | ||
| return <SpecialButton2 onClick={async () => { | ||
| await new Promise((res) => setTimeout(res, 1000)); | ||
| return { success: true }; | ||
| }} /> | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Environment variable reference syntax is incorrect. In .env files, variable expansion like ${GITHUB_TOKEN_READONLY} typically doesn't work as expected. This should either be a direct value or the consuming code should handle the indirection.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Explain.