* Add Stack Exchange Liquid tag * Add Stack Exchange/Overflow tag * Convert to integers * Add better error handling * Make all links open in new tab * Adjust names and refactor a bit * Use key for every API call * Add new lines to end of svg files * Add better error handling * Fix edge case where input is not numeric * Finalize Stackexhange tag design and functionality * Fix css typo * Update snapshots * Fix snapshot back
74 lines
1.7 KiB
JavaScript
74 lines
1.7 KiB
JavaScript
import { h } from 'preact';
|
|
import PropTypes from 'prop-types';
|
|
|
|
const PublishToggle = ({
|
|
previewShowing,
|
|
onPreview,
|
|
onSaveDraft,
|
|
onPublish,
|
|
onHelp,
|
|
published,
|
|
helpShowing,
|
|
edited,
|
|
version,
|
|
onClearChanges,
|
|
}) => (
|
|
<div className="articleform__buttons">
|
|
<button
|
|
onClick={onHelp}
|
|
type="button"
|
|
className={
|
|
helpShowing
|
|
? 'articleform__buttons--small active'
|
|
: 'articleform__buttons--small inactive'
|
|
}
|
|
>
|
|
?
|
|
</button>
|
|
<button
|
|
onClick={onPreview}
|
|
type="button"
|
|
className={previewShowing ? 'active previewbutt' : 'inactive previewbutt'}
|
|
>
|
|
{previewShowing ? 'EDIT' : 'PREVIEW'}
|
|
</button>
|
|
{published || version === 'v1' ? (
|
|
''
|
|
) : (
|
|
<button onClick={onSaveDraft} type="button">
|
|
SAVE DRAFT
|
|
</button>
|
|
)}
|
|
<span>
|
|
<p style={!edited && { visibility: 'hidden' }}>
|
|
New Changes (
|
|
<button onClick={onClearChanges} className="clear-button" type="button">
|
|
clear
|
|
</button>
|
|
)
|
|
</p>
|
|
<button
|
|
onClick={onPublish}
|
|
className="articleform__buttons--publish"
|
|
type="button"
|
|
>
|
|
{published || version === 'v1' ? 'SAVE CHANGES' : 'PUBLISH'}
|
|
</button>
|
|
</span>
|
|
</div>
|
|
);
|
|
|
|
PublishToggle.propTypes = {
|
|
previewShowing: PropTypes.bool.isRequired,
|
|
onPreview: PropTypes.func.isRequired,
|
|
onSaveDraft: PropTypes.func.isRequired,
|
|
onPublish: PropTypes.func.isRequired,
|
|
onHelp: PropTypes.func.isRequired,
|
|
published: PropTypes.bool.isRequired,
|
|
helpShowing: PropTypes.bool.isRequired,
|
|
edited: PropTypes.bool.isRequired,
|
|
version: PropTypes.string.isRequired,
|
|
onClearChanges: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default PublishToggle;
|