-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade ui lib. add share target to wishwash
- Loading branch information
Showing
25 changed files
with
260 additions
and
141 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
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
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
67 changes: 67 additions & 0 deletions
67
apps/wish-wash/web/src/components/shareTarget/ShareTargetListPicker.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,67 @@ | ||
import { useSnapshot } from 'valtio'; | ||
import { shareTargetState } from './shareTargetState.js'; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogActions, | ||
DialogClose, | ||
DialogSelectItem, | ||
DialogSelectList, | ||
DialogTitle, | ||
} from '@a-type/ui/components/dialog'; | ||
import { hooks } from '@/store.js'; | ||
import { useNavigate } from '@verdant-web/react-router'; | ||
import { Icon } from '@a-type/ui/components/icon'; | ||
|
||
export interface ShareTargetListPickerProps {} | ||
|
||
export function ShareTargetListPicker({}: ShareTargetListPickerProps) { | ||
const share = useSnapshot(shareTargetState).share; | ||
|
||
const show = !!share; | ||
|
||
const client = hooks.useClient(); | ||
const navigate = useNavigate(); | ||
const addToList = async (listId: string) => { | ||
if (!share) return; | ||
await client.items.put({ | ||
listId, | ||
link: share.url, | ||
description: share.title || share.text, | ||
}); | ||
navigate(`/${listId}`); | ||
}; | ||
|
||
return ( | ||
<Dialog | ||
open={show} | ||
onOpenChange={(open) => { | ||
if (!open) { | ||
shareTargetState.share = null; | ||
} | ||
}} | ||
> | ||
<DialogContent> | ||
<DialogTitle>Add to list</DialogTitle> | ||
<DialogSelectList onValueChange={addToList}> | ||
{show && <ListItems />} | ||
</DialogSelectList> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
} | ||
|
||
const ListItems = () => { | ||
const lists = hooks.useAllLists(); | ||
|
||
return ( | ||
<> | ||
{lists.map((list) => ( | ||
<DialogSelectItem value={list.get('id')} key={list.get('id')}> | ||
<Icon name={list.isAuthorized ? 'lock' : 'add_person'} /> | ||
{list.get('name')} | ||
</DialogSelectItem> | ||
))} | ||
</> | ||
); | ||
}; |
10 changes: 10 additions & 0 deletions
10
apps/wish-wash/web/src/components/shareTarget/shareTargetState.ts
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,10 @@ | ||
import { onShare, ShareData } from '@biscuits/client'; | ||
import { proxy } from 'valtio'; | ||
|
||
export const shareTargetState = proxy({ | ||
share: null as null | ShareData, | ||
}); | ||
|
||
onShare((share) => { | ||
shareTargetState.share = share; | ||
}); |
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.