Skip to content

Commit

Permalink
Sticker upload affordances, fix 'recent media'
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Nonnenberg <scott@signal.org>
  • Loading branch information
automated-signal and scottnonnenberg-signal committed Oct 13, 2021
1 parent 402ce1d commit b08d163
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 6 deletions.
8 changes: 8 additions & 0 deletions _locales/en/messages.json
Expand Up @@ -3015,6 +3015,14 @@
"message": "Add your stickers",
"description": "Title for the drop stage of the sticker creator"
},
"StickerCreator--DropStage--removeSticker": {
"message": "Remove sticker",
"description": "Label for the X button used to remove a staged sticker"
},
"StickerCreator--DropStage--dragDrop": {
"message": "Click or drag/drop a file to add a sticker",
"description": "Shown on the + section of the file addition stage of sticker pack creation"
},
"StickerCreator--DropStage--help": {
"message": "Stickers must be in PNG, APNG, or WebP format with a transparent background and 512x512 pixels. Recommended margin is 16px.",
"description": "Help text for the drop stage of the sticker creator"
Expand Down
8 changes: 7 additions & 1 deletion sticker-creator/components/StickerFrame.tsx
Expand Up @@ -202,11 +202,17 @@ export const StickerFrame = React.memo(
<div className={styles.guide} />
) : null}
{mode === 'add' && onDrop ? (
<DropZone onDrop={onDrop} inner onDragActive={setDragActive} />
<DropZone
label={i18n('StickerCreator--DropStage--dragDrop')}
onDrop={onDrop}
inner
onDragActive={setDragActive}
/>
) : null}
{mode === 'removable' ? (
<button
type="button"
aria-label={i18n('StickerCreator--DropStage--removeSticker')}
className={styles.closeButton}
onClick={handleRemove}
// Reverse the mouseenter/leave logic for the remove button so
Expand Down
7 changes: 6 additions & 1 deletion sticker-creator/components/StickerGrid.tsx
Expand Up @@ -13,6 +13,7 @@ import { Props as StickerFrameProps, StickerFrame } from './StickerFrame';
import { stickersDuck } from '../store';
import { DropZone, Props as DropZoneProps } from '../elements/DropZone';
import { processStickerImage } from '../util/preload';
import { useI18n } from '../util/i18n';

const queue = new PQueue({ concurrency: 3, timeout: 1000 * 60 * 2 });

Expand Down Expand Up @@ -44,6 +45,7 @@ export type InnerGridProps = Props & {

const InnerGrid = SortableContainer(
({ ids, mode, showGuide }: InnerGridProps) => {
const i18n = useI18n();
const containerClassName = ids.length > 0 ? styles.grid : styles.drop;
const frameMode = mode === 'add' ? 'removable' : 'pick-emoji';

Expand Down Expand Up @@ -94,7 +96,10 @@ const InnerGrid = SortableContainer(
) : null}
</>
) : (
<DropZone onDrop={handleDrop} />
<DropZone
label={i18n('StickerCreator--DropStage--dragDrop')}
onDrop={handleDrop}
/>
)}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion sticker-creator/elements/DropZone.stories.tsx
Expand Up @@ -8,5 +8,5 @@ import { action } from '@storybook/addon-actions';
import { DropZone } from './DropZone';

storiesOf('Sticker Creator/elements', module).add('DropZone', () => {
return <DropZone onDrop={action('onDrop')} />;
return <DropZone label="This is the label" onDrop={action('onDrop')} />;
});
4 changes: 3 additions & 1 deletion sticker-creator/elements/DropZone.tsx
Expand Up @@ -9,6 +9,7 @@ import { useStickerDropzone } from '../util/useStickerDropzone';

export type Props = {
readonly inner?: boolean;
readonly label: string;
onDrop(files: Array<string>): unknown;
onDragActive?(active: boolean): unknown;
};
Expand All @@ -26,7 +27,7 @@ const getClassName = ({ inner }: Props, isDragActive: boolean) => {
};

export const DropZone: React.ComponentType<Props> = props => {
const { inner, onDrop, onDragActive } = props;
const { inner, label, onDrop, onDragActive } = props;
const i18n = useI18n();

const handleDrop = React.useCallback(
Expand All @@ -50,6 +51,7 @@ export const DropZone: React.ComponentType<Props> = props => {
<div
{...getRootProps({ className: getClassName(props, isDragActive) })}
role="button"
area-label={label}
>
<input {...getInputProps()} />
<svg viewBox="0 0 36 36" width="36px" height="36px">
Expand Down
9 changes: 8 additions & 1 deletion sticker-creator/elements/LabeledCheckbox.scss
Expand Up @@ -8,6 +8,14 @@
display: flex;
flex-direction: row;
align-items: center;

padding: 2px;

// We'd really like to use focus-within-visible or :has(:focus-visible), to ensure that
// this doesn't show when using the mouse, but neither are ready yet!
&:focus-within {
outline: 2px solid -webkit-focus-ring-color;
}
}

.input {
Expand Down Expand Up @@ -48,6 +56,5 @@
.label {
margin-left: 6px;
position: relative;
top: 1px;
user-select: none;
}
2 changes: 1 addition & 1 deletion ts/views/conversation_view.ts
Expand Up @@ -1870,7 +1870,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
}

showAllMedia(): void {
if (this.panels && this.panels.length) {
if (document.querySelectorAll('.module-media-gallery').length) {
return;
}

Expand Down

0 comments on commit b08d163

Please sign in to comment.