diff options
author | neatchee <neatchee@gmail.com> | 2023-01-26 10:36:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-26 19:36:44 +0100 |
commit | 20abef6590505d12aca81ed1c386804d75b8b552 (patch) | |
tree | 5eab629626e516b1efda81cb6b6dad5d389dd64b /app/javascript/flavours/glitch/features/local_settings | |
parent | 7acf26e7778f8bb2b62c61904547dec75723c203 (diff) |
Allow users to set the trigger height for lengthy toot auto-collapse (#2070)
* Allow users to set the trigger height for lengthy toot autocollapse Add a field in the glitch-soc preferences to set the exact height in pixels of a "lengthy toot" where auto-collapse is triggered Originally authored by Dean Bassett (github.com/deanveloper) Squashed 3 commits from neatchee/mastodon and returned some values to project defaults: * ef665c1df5821e684c8da3392049f33243fafa74 * 0fce108d210efe55027a3af061bfc57aaaa83843 * 998f701a2b2e37edbda7dffb11a61f67f5559b18 * Remove bad escape characters * Apply feedback from glitch-soc code review - move input width specification to CSS - adjust language for clarity * Update comments re: lengthy toot height * Fix inconsistent indentation * Use a calculated width that scales better with browser font instead of static 45px width
Diffstat (limited to 'app/javascript/flavours/glitch/features/local_settings')
-rw-r--r-- | app/javascript/flavours/glitch/features/local_settings/page/index.js | 14 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/features/local_settings/page/item/index.js | 14 |
2 files changed, 23 insertions, 5 deletions
diff --git a/app/javascript/flavours/glitch/features/local_settings/page/index.js b/app/javascript/flavours/glitch/features/local_settings/page/index.js index d01eec811..d1573da9c 100644 --- a/app/javascript/flavours/glitch/features/local_settings/page/index.js +++ b/app/javascript/flavours/glitch/features/local_settings/page/index.js @@ -5,7 +5,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import { defineMessages, FormattedMessage, injectIntl } from 'react-intl'; // Our imports -import { expandSpoilers, disableSwiping } from 'flavours/glitch/initial_state'; +import { expandSpoilers } from 'flavours/glitch/initial_state'; import { preferenceLink } from 'flavours/glitch/utils/backend_links'; import LocalSettingsPageItem from './item'; import DeprecatedLocalSettingsPageItem from './deprecated_item'; @@ -406,6 +406,18 @@ class LocalSettingsPage extends React.PureComponent { > <FormattedMessage id='settings.auto_collapse_media' defaultMessage='Toots with media' /> </LocalSettingsPageItem> + <LocalSettingsPageItem + settings={settings} + item={['collapsed', 'auto', 'height']} + id='mastodon-settings--collapsed-auto-height' + placeholder='400' + onChange={onChange} + dependsOn={[['collapsed', 'enabled']]} + dependsOnNot={[['collapsed', 'auto', 'all']]} + inputProps={{type: 'number', min: '200', max: '999'}} + > + <FormattedMessage id='settings.auto_collapse_height' defaultMessage='Height (in pixels) for a toot to be considered lengthy' /> + </LocalSettingsPageItem> </section> <section> <h2><FormattedMessage id='settings.image_backgrounds' defaultMessage='Image backgrounds' /></h2> diff --git a/app/javascript/flavours/glitch/features/local_settings/page/item/index.js b/app/javascript/flavours/glitch/features/local_settings/page/item/index.js index 6b24e4143..86da640ba 100644 --- a/app/javascript/flavours/glitch/features/local_settings/page/item/index.js +++ b/app/javascript/flavours/glitch/features/local_settings/page/item/index.js @@ -14,6 +14,7 @@ export default class LocalSettingsPageItem extends React.PureComponent { id: PropTypes.string.isRequired, item: PropTypes.array.isRequired, onChange: PropTypes.func.isRequired, + inputProps: PropTypes.object, options: PropTypes.arrayOf(PropTypes.shape({ value: PropTypes.string.isRequired, message: PropTypes.string.isRequired, @@ -34,7 +35,7 @@ export default class LocalSettingsPageItem extends React.PureComponent { render () { const { handleChange } = this; - const { settings, item, id, options, children, dependsOn, dependsOnNot, placeholder, disabled } = this.props; + const { settings, item, id, inputProps, options, children, dependsOn, dependsOnNot, placeholder, disabled } = this.props; let enabled = !disabled; if (dependsOn) { @@ -54,14 +55,17 @@ export default class LocalSettingsPageItem extends React.PureComponent { let optionId = `${id}--${opt.value}`; return ( <label htmlFor={optionId}> - <input type='radio' + <input + type='radio' name={id} id={optionId} + key={optionId} value={opt.value} onBlur={handleChange} onChange={handleChange} - checked={ currentValue === opt.value } + checked={currentValue === opt.value} disabled={!enabled} + {...inputProps} /> {opt.message} {opt.hint && <span className='hint'>{opt.hint}</span>} @@ -89,6 +93,7 @@ export default class LocalSettingsPageItem extends React.PureComponent { placeholder={placeholder} onChange={handleChange} disabled={!enabled} + {...inputProps} /> </p> </label> @@ -103,7 +108,8 @@ export default class LocalSettingsPageItem extends React.PureComponent { checked={settings.getIn(item)} onChange={handleChange} disabled={!enabled} - /> + {...inputProps} + /> {children} </label> </div> |