-
-
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.
Improved private / public view toggle
- Loading branch information
1 parent
fe18f11
commit 60f5303
Showing
5 changed files
with
120 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import { Globe, Lock } from 'lucide-react'; | ||
|
||
interface ViewSwitchProps { | ||
checked: boolean; | ||
onChange: (checked: boolean) => void; | ||
} | ||
|
||
const ViewSwitch: React.FC<ViewSwitchProps> = ({ checked, onChange }) => { | ||
return ( | ||
<div className="flex items-center gap-3 text-sm text-light-text dark:text-dark-text w-full"> | ||
<div | ||
className="flex gap-0.5 rounded-lg bg-light-secondary dark:bg-dark-secondary px-0.5 py-0.5 w-full" | ||
role="group" | ||
> | ||
<button | ||
type="button" | ||
onClick={() => onChange(false)} | ||
className={` | ||
flex items-center justify-center gap-1 px-2 py-0.5 rounded-md transition-all duration-200 flex-1 | ||
${!checked | ||
? 'bg-light-hover dark:bg-dark-hover' | ||
: 'hover:bg-light-hover/50 dark:hover:bg-dark-hover/50' | ||
} | ||
`} | ||
> | ||
<Lock | ||
className={` | ||
stroke-[2] transition-colors duration-200 | ||
${!checked ? 'text-emerald-500' : 'text-light-text/50 dark:text-dark-text/50'} | ||
`} | ||
size={14} | ||
/> | ||
<span className="text-xs font-medium">Private</span> | ||
</button> | ||
<button | ||
type="button" | ||
onClick={() => onChange(true)} | ||
className={` | ||
flex items-center justify-center gap-1 px-2 py-0.5 rounded-md transition-all duration-200 flex-1 | ||
${checked | ||
? 'bg-light-hover dark:bg-dark-hover' | ||
: 'hover:bg-light-hover/50 dark:hover:bg-dark-hover/50' | ||
} | ||
`} | ||
> | ||
<Globe | ||
className={` | ||
stroke-[2] transition-colors duration-200 | ||
${checked ? 'text-light-primary dark:text-dark-primary' : 'text-light-text/50 dark:text-dark-text/50'} | ||
`} | ||
size={14} | ||
/> | ||
<span className="text-xs font-medium">Public</span> | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ViewSwitch; |
36 changes: 36 additions & 0 deletions
36
client/src/components/snippets/view/common/ViewToggleButton.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,36 @@ | ||
import React from 'react'; | ||
import { Globe, Lock } from 'lucide-react'; | ||
import { Link } from 'react-router-dom'; | ||
import { ROUTES } from '../../../../constants/routes'; | ||
|
||
interface ViewToggleButtonProps { | ||
isPublicView: boolean; | ||
} | ||
|
||
const ViewToggleButton: React.FC<ViewToggleButtonProps> = ({ isPublicView }) => { | ||
const toggleProps = isPublicView | ||
? { | ||
to: ROUTES.HOME, | ||
icon: <Lock className="w-4 h-4" />, | ||
text: "Switch to private", | ||
className: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20" | ||
} | ||
: { | ||
to: ROUTES.PUBLIC_SNIPPETS, | ||
icon: <Globe className="w-4 h-4" />, | ||
text: "Switch to public", | ||
className: "bg-light-primary/10 text-light-primary dark:text-dark-primary hover:bg-light-primary/20" | ||
}; | ||
|
||
return ( | ||
<Link | ||
to={toggleProps.to} | ||
className={`flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${toggleProps.className}`} | ||
> | ||
{toggleProps.icon} | ||
<span>{toggleProps.text}</span> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default ViewToggleButton; |
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