-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds space-finder autocomplete combobox (#268)
Riffing on #266 - add a space-finder combobox based on https://headlessui.com/react/combobox - updates w3console layout to look fancy ![w3console](https://user-images.githubusercontent.com/58871/213501204-ef2432f3-c52e-46ed-ac9b-9702771c4259.gif) Signed-off-by: Oli Evans <[email protected]> Co-authored-by: Travis Vachon <[email protected]>
- Loading branch information
Showing
14 changed files
with
823 additions
and
241 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
38 changes: 38 additions & 0 deletions
38
examples/react/playground/src/stories/SpaceList.stories.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,38 @@ | ||
import type { DID } from '@ucanto/interface' | ||
import type { KeyringContextValue } from '@w3ui/react-keyring' | ||
|
||
import React from 'react' | ||
import { SpaceList } from '@w3ui/react' | ||
import { Space } from '@w3ui/keyring-core' | ||
import { KeyringContext, keyringContextDefaultValue } from '@w3ui/react-keyring' | ||
|
||
function contextValue (state = {}, actions = {}): KeyringContextValue { | ||
return [ | ||
{ ...keyringContextDefaultValue[0], ...state }, | ||
{ ...keyringContextDefaultValue[1], ...actions } | ||
] | ||
} | ||
|
||
function WrappedSpaceList ({ spaceDIDs = [], setCurrentSpace }: { spaceDIDs: DID[], setCurrentSpace: any }): JSX.Element { | ||
const spaces = spaceDIDs.map(did => new Space(did, {})) | ||
return ( | ||
<KeyringContext.Provider value={contextValue({ spaces }, { setCurrentSpace })}> | ||
<SpaceList /> | ||
</KeyringContext.Provider> | ||
) | ||
} | ||
|
||
export default { | ||
title: 'w3ui/SpaceList', | ||
component: WrappedSpaceList, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
setCurrentSpace: { action: 'set space' } | ||
} | ||
} | ||
|
||
export const Primary = { | ||
args: { | ||
spaceDIDs: ['did:example:abc123'] | ||
} | ||
} |
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
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
Oops, something went wrong.