-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added lots of settings and markdown editor on react example
- Loading branch information
1 parent
a975f11
commit 153dd41
Showing
6 changed files
with
292 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { | ||
IconAt, | ||
IconBrandX, | ||
IconBrandYoutube, | ||
IconExternalLink, | ||
IconHash, | ||
IconLink, | ||
IconMovie, | ||
IconPhoto, | ||
IconQuote, | ||
} from '@tabler/icons-react' | ||
|
||
import { Switch } from './components/settings/Switch' | ||
import type { EditorType } from './types' | ||
|
||
type Props = { | ||
type: EditorType | ||
onChangeEditor: (type: 'text' | 'markdown') => void | ||
onChangeExtensions: (name: string, value: boolean) => void | ||
} | ||
|
||
export function Sidebar(props: Props) { | ||
const handleChange = (name: string) => (value: boolean) => { | ||
props.onChangeExtensions(name, value) | ||
} | ||
|
||
const activeColor = (value: EditorType) => (props.type === value ? 'bg-blue-500 text-white' : 'bg-gray-200') | ||
|
||
return ( | ||
<nav className='fixed h-full right-0 w-5 bg-gray-100 px-8 py-14' style={{ width: 400 }}> | ||
<h3>Settings</h3> | ||
<div className='my-4'> | ||
<button | ||
className={`rounded-full px-3 mr-1 ${activeColor('text')}`} | ||
onClick={() => props.onChangeEditor('text')}> | ||
Text | ||
</button> | ||
<button | ||
className={`rounded-full px-3 mr-1 ${activeColor('markdown')}`} | ||
onClick={() => props.onChangeEditor('markdown')}> | ||
Markdown | ||
</button> | ||
<button className='rounded-full px-3 mr-1 bg-gray-100'>Asciidoc (soon)</button> | ||
</div> | ||
<h3>Extensions</h3> | ||
<div className='mt-4'> | ||
<Switch icon={IconQuote} label='nevent1' onChange={handleChange('nevent1')} /> | ||
<Switch icon={IconAt} label='nprofile1' onChange={handleChange('nprofile1')} /> | ||
<Switch icon={IconExternalLink} label='naddr1' onChange={handleChange('naddr1')} /> | ||
<Switch icon={IconLink} label='Links' onChange={handleChange('links')} /> | ||
<Switch icon={IconPhoto} label='Images' onChange={handleChange('images')} /> | ||
<Switch icon={IconHash} label='Tags' onChange={handleChange('tags')} /> | ||
<Switch icon={IconMovie} label='Videos' onChange={handleChange('videos')} /> | ||
<Switch icon={IconBrandYoutube} label='Youtube' onChange={handleChange('youtube')} /> | ||
<Switch icon={IconBrandX} label='Tweets' onChange={handleChange('tweet')} /> | ||
</div> | ||
</nav> | ||
) | ||
} |
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,17 @@ | ||
export const TestText = () => ( | ||
<> | ||
<h6>testing text</h6> | ||
<span id='raw' className='text-xs break-all text-wrap z-20 relative'> | ||
Hello | ||
nostr:nprofile1qy88wumn8ghj7mn0wvhxcmmv9uq32amnwvaz7tmjv4kxz7fwv3sk6atn9e5k7tcprfmhxue69uhhyetvv9ujuem9w3skccne9e3k7mf0wccsqgxxvqas78x0a339m8qgkaf7fam5atmarne8dy3rzfd4l4x6w2qpncmfs8zh | ||
and | ||
nostr:nprofile1qyd8wumn8ghj7urewfsk66ty9enxjct5dfskvtnrdakj7qgmwaehxw309aex2mrp0yh8wetnw3jhymnzw33jucm0d5hsz9thwden5te0wfjkccte9ejxzmt4wvhxjme0qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gfnma0u | ||
and | ||
nostr:nprofile1qyfhwumn8ghj7ur4wfcxcetsv9njuetn9uqsuamnwvaz7tmwdaejumr0dshsz9mhwden5te0wfjkccte9ec8y6tdv9kzumn9wshsqgyzxs0cs2mw40xjhfl3a7g24ktpeur54u2mnm6y5z0e6250h7lx5gflu83m | ||
<br /> | ||
nostr:nevent1qvzqqqqqqypzplnld0r0wvutw6alsrd5q2k7vk2nug9j7glxd6ycyp9k8nzz2wdrqyg8wumn8ghj7mn0wd68ytnhd9hx2qg5waehxw309aex2mrp0yhxgctdw4eju6t0qyxhwumn8ghj7mn0wvhxcmmvqqs9gg4thq8ng87z8377jxksjwhk9dl0f8su9c4kq335ydzp0ykmv5gqt3csa | ||
<br /> | ||
image: https://image.nostr.build/87dbc55a6391d15bddda206561d53867a5679dd95e84fe8ed62bfe2e3adcadf3.jpg | ||
</span> | ||
</> | ||
) |
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,27 @@ | ||
import type { Icon, IconProps } from '@tabler/icons-react' | ||
|
||
type Props = { | ||
label: string | ||
defaultChecked?: boolean | ||
icon?: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<Icon>> | ||
onChange: (value: boolean) => void | ||
} | ||
|
||
export function Switch(props: Props) { | ||
const { defaultChecked = true } = props | ||
const Icon = props.icon | ||
return ( | ||
<label className='w-full mb-4 flex items-center cursor-pointer justify-between'> | ||
<span className='text-sm font-medium text-gray-900 flex flex-row align-center justify-center'> | ||
{Icon && <Icon strokeWidth='1.5' size={28} />} <span className='ml-4 leading-6'>{props.label}</span> | ||
</span> | ||
<input | ||
type='checkbox' | ||
defaultChecked={defaultChecked} | ||
onChange={(event) => props.onChange(event.target.checked)} | ||
className='sr-only peer' | ||
/> | ||
<div className="relative w-11 h-6 bg-gray-200 peer-focus:outline-none dark:peer-focus:ring-blue-600 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div> | ||
</label> | ||
) | ||
} |
Oops, something went wrong.