forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WiP] Add secondary post button back
- Loading branch information
1 parent
625b719
commit cdf9499
Showing
3 changed files
with
76 additions
and
0 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
44 changes: 44 additions & 0 deletions
44
app/javascript/flavours/glitch/features/compose/components/secondary_privacy_button.jsx
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,44 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
import { useIntl, defineMessages } from 'react-intl'; | ||
|
||
import LockIcon from '@/material-icons/400-24px/lock.svg?react'; | ||
import MailIcon from '@/material-icons/400-24px/mail.svg?react'; | ||
import PublicIcon from '@/material-icons/400-24px/public.svg?react'; | ||
import QuietTimeIcon from '@/material-icons/400-24px/quiet_time.svg?react'; | ||
import { Button } from 'flavours/glitch/components/button'; | ||
import { Icon } from 'flavours/glitch/components/icon'; | ||
|
||
const messages = defineMessages({ | ||
public: { id: 'privacy.public.short', defaultMessage: 'Public' }, | ||
unlisted: { id: 'privacy.unlisted.short', defaultMessage: 'Quiet public' }, | ||
private: { id: 'privacy.private.short', defaultMessage: 'Followers' }, | ||
direct: { id: 'privacy.direct.short', defaultMessage: 'Specific people' }, | ||
}); | ||
|
||
export const SecondaryPrivacyButton = ({ privacy, isEditing, onClick }) => { | ||
const intl = useIntl(); | ||
|
||
if (isEditing || !privacy || privacy === 'none') { | ||
return null; | ||
} | ||
|
||
const privacyProps = { | ||
direct: { icon: 'envelope', iconComponent: MailIcon, title: messages.direct }, | ||
private: { icon: 'lock', iconComponent: LockIcon, title: messages.private }, | ||
public: { icon: 'globe', iconComponent: PublicIcon, title: messages.public }, | ||
unlisted: { icon: 'unlock', iconComponent: QuietTimeIcon, title: messages.unlisted }, | ||
}; | ||
|
||
return ( | ||
<Button className='secondary-post-button' onClick={onClick} title={intl.formatMessage(privacyProps[privacy].title)}> | ||
<Icon id={privacyProps[privacy].id} icon={privacyProps[privacy].iconComponent} /> | ||
</Button> | ||
); | ||
}; | ||
|
||
SecondaryPrivacyButton.propTypes = { | ||
privacy: PropTypes.string, | ||
isEditing: PropTypes.bool, | ||
onClick: PropTypes.func.isRequired, | ||
}; |
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