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.
- Loading branch information
1 parent
665fdff
commit b749373
Showing
9 changed files
with
111 additions
and
75 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
app/javascript/flavours/glitch/components/collapse_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,45 @@ | ||
import PropTypes from 'prop-types'; | ||
import { useCallback } from 'react'; | ||
|
||
import { defineMessages, useIntl } from 'react-intl'; | ||
|
||
import ExpandLessIcon from '@/material-icons/400-24px/expand_less.svg?react'; | ||
|
||
import { IconButton } from './icon_button'; | ||
|
||
const messages = defineMessages({ | ||
collapse: { id: 'status.collapse', defaultMessage: 'Collapse' }, | ||
uncollapse: { id: 'status.uncollapse', defaultMessage: 'Uncollapse' }, | ||
}); | ||
|
||
export const CollapseButton = ({ collapsed, setCollapsed }) => { | ||
const intl = useIntl(); | ||
|
||
const handleCollapsedClick = useCallback((e) => { | ||
if (e.button === 0) { | ||
setCollapsed(!collapsed); | ||
e.preventDefault(); | ||
} | ||
}, [collapsed, setCollapsed]); | ||
|
||
return ( | ||
<IconButton | ||
className='status__collapse-button' | ||
animate | ||
active={collapsed} | ||
title={ | ||
collapsed ? | ||
intl.formatMessage(messages.uncollapse) : | ||
intl.formatMessage(messages.collapse) | ||
} | ||
icon='angle-double-up' | ||
iconComponent={ExpandLessIcon} | ||
onClick={handleCollapsedClick} | ||
/> | ||
); | ||
}; | ||
|
||
CollapseButton.propTypes = { | ||
collapsed: PropTypes.bool, | ||
setCollapsed: 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
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