-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Slots #1
Merged
Merged
Slots #1
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1eca42b
wip slots
steppy452 4b6fd72
update console story
steppy452 ef64819
fix invalid hook use
amcdnl 858f918
session groups
amcdnl 57b0b48
reorganize
amcdnl 9ca827d
fix type
amcdnl e1d56ae
mke date themable
amcdnl 20e36e7
fix tash icon sizes
amcdnl 1533fd1
add divider
amcdnl 3ad5646
make viewtype optionmal
amcdnl 2bb4a44
tweak readme
amcdnl 32dae2b
add paragraph padding
amcdnl 7893337
embeds support
amcdnl b3b2256
rearrange plugins
amcdnl aeec720
add notes
amcdnl fe383a6
imply asChild given children
steppy452 92a59b2
fixup
steppy452 8804f3b
update stories
steppy452 95945f9
improve long session names styling
steppy452 c5dc529
more custom components
steppy452 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 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 |
---|---|---|
|
@@ -114,5 +114,6 @@ | |
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
} | ||
}, | ||
"packageManager": "[email protected]+sha1.8c155dc114e1689d18937974f6571e0ceee66f1d" | ||
} |
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,29 @@ | ||
import { Button, cn } from 'reablocks'; | ||
import { FC, PropsWithChildren, useContext } from 'react'; | ||
import { SessionsContext } from './SessionsContext'; | ||
import { Slot } from '@radix-ui/react-slot'; | ||
|
||
interface NewSessionButtonProps extends PropsWithChildren { | ||
asChild?: boolean; | ||
newSessionText?: string; | ||
} | ||
|
||
export const NewSessionButton: FC<NewSessionButtonProps> = ({ | ||
children, | ||
asChild, | ||
newSessionText = 'New Session' | ||
}) => { | ||
const { theme, createSession } = useContext(SessionsContext); | ||
const Comp = asChild ? Slot : Button; | ||
return ( | ||
<Comp | ||
fullWidth | ||
disableMargins | ||
color="primary" | ||
className={cn(theme.sessions.create)} | ||
onClick={createSession} | ||
> | ||
{asChild ? children : newSessionText} | ||
</Comp> | ||
); | ||
}; |
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,14 @@ | ||
import { FC, ReactNode, useContext } from 'react'; | ||
import { SessionsContext } from './SessionsContext'; | ||
import { cn } from 'reablocks'; | ||
|
||
interface SessionEmptyProps { | ||
newSessionContent?: string | ReactNode; | ||
} | ||
|
||
export const SessionEmpty: FC<SessionEmptyProps> = ({ | ||
newSessionContent = '' | ||
}) => { | ||
const { theme } = useContext(SessionsContext); | ||
return <div className={cn(theme.empty)}>{newSessionContent}</div>; | ||
}; |
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 |
---|---|---|
@@ -1,72 +1,60 @@ | ||
import { FC, ReactElement } from 'react'; | ||
import { FC, ReactElement, ReactNode, useContext } from 'react'; | ||
import { ListItem, IconButton, cn, Ellipsis } from 'reablocks'; | ||
import { Session } from './types'; | ||
import TrashIcon from '@/assets/trash.svg?react'; | ||
import { ChatTheme } from './theme'; | ||
import { SessionsContext } from './SessionsContext'; | ||
import { Slot } from '@radix-ui/react-slot'; | ||
|
||
interface SessionListItemProps { | ||
/** | ||
* Theme to use for the session list item. | ||
*/ | ||
theme?: ChatTheme; | ||
asChild?: boolean; | ||
children?: ReactNode; | ||
|
||
/** | ||
* Session to display. | ||
*/ | ||
session: Session; | ||
|
||
/** | ||
* Indicates whether this session is currently active | ||
*/ | ||
isActive: boolean; | ||
|
||
/** | ||
* Icon to show for delete. | ||
*/ | ||
deleteIcon?: ReactElement; | ||
|
||
/** | ||
* Callback function to handle session selection, receives the session ID | ||
*/ | ||
onSelectSession?: (sessionId: string) => void; | ||
|
||
/** | ||
* Callback function to handle session deletion, receives the session ID | ||
*/ | ||
onDeleteSession?: (sessionId: string) => void; | ||
} | ||
|
||
export const SessionListItem: FC<SessionListItemProps> = ({ | ||
children, | ||
asChild, | ||
session, | ||
isActive, | ||
theme, | ||
onSelectSession, | ||
onDeleteSession, | ||
deleteIcon = <TrashIcon className={cn(theme.sessions.session.delete)} /> | ||
}) => ( | ||
<ListItem | ||
dense | ||
disableGutters | ||
active={isActive} | ||
className={cn(theme.sessions.session.base)} | ||
onClick={() => onSelectSession?.(session.id)} | ||
end={ | ||
<> | ||
{onDeleteSession && ( | ||
<IconButton | ||
size="small" | ||
variant="text" | ||
onClick={(e) => { | ||
e.stopPropagation(); | ||
onDeleteSession(session.id); | ||
}} | ||
> | ||
{deleteIcon} | ||
</IconButton> | ||
)} | ||
</> | ||
} | ||
> | ||
<Ellipsis value={session.title} limit={100} /> | ||
</ListItem> | ||
); | ||
deleteIcon = <TrashIcon /> | ||
}) => { | ||
const { activeSessionId, selectSession, deleteSession, theme } = | ||
useContext(SessionsContext); | ||
const Comp = asChild ? Slot : ListItem; | ||
return ( | ||
<Comp | ||
dense | ||
disableGutters | ||
active={session.id === activeSessionId} | ||
className={cn(theme.sessions.session.base)} | ||
onClick={() => selectSession?.(session.id)} | ||
end={ | ||
<> | ||
{deleteSession && ( | ||
<IconButton | ||
size="small" | ||
variant="text" | ||
onClick={e => { | ||
e.stopPropagation(); | ||
deleteSession(session.id); | ||
}} | ||
className={cn(theme.sessions.session.delete)} | ||
> | ||
{deleteIcon} | ||
</IconButton> | ||
)} | ||
</> | ||
} | ||
> | ||
{asChild ? children : <Ellipsis value={session.title} limit={100} />} | ||
</Comp> | ||
); | ||
}; |
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.
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.
pnpm?