Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation: Direction UI Component #4143

Merged
merged 7 commits into from Aug 21, 2020

Conversation

littlemilkstudio
Copy link
Contributor

Summary

Adds a custom radio input for selection of our directions.

Relevant Technical Choices

Felt like a radio input, so I made it one 馃

To-do

NA

User-facing changes

none

Testing Instructions

run storybook -> Animations / Direction Radio Input -> click & up/down arrow through to options to validate keyboard accessibility.

Also added unit tests which will be validated by CI.

direction_select


Fixes #3794

@github-actions
Copy link
Contributor

github-actions bot commented Aug 20, 2020

Size Change: +5.28 kB (0%)

Total Size: 1.16 MB

Filename Size Change
assets/js/edit-story.js 486 kB +2.34 kB (0%)
assets/js/stories-dashboard.js 512 kB +3.02 kB (0%)
鈩癸笍 View Unchanged
Filename Size Change
assets/css/edit-story.css 268 B 0 B
assets/css/stories-dashboard.css 305 B 0 B
assets/css/web-stories-embed-block.css 515 B 0 B
assets/js/chunk-web-stories-template-0-********************.js 10.2 kB 0 B
assets/js/chunk-web-stories-template-1-********************.js 10.3 kB 0 B
assets/js/chunk-web-stories-template-2-********************.js 10 kB 0 B
assets/js/chunk-web-stories-template-3-********************.js 10.5 kB 0 B
assets/js/chunk-web-stories-template-4-********************.js 10.6 kB 0 B
assets/js/chunk-web-stories-template-5-********************.js 6.86 kB -70 B (1%)
assets/js/chunk-web-stories-template-6-********************.js 9.91 kB 0 B
assets/js/chunk-web-stories-template-7-********************.js 9.78 kB 0 B
assets/js/web-stories-activation-notice.js 63.6 kB 0 B
assets/js/web-stories-embed-block.js 16.9 kB 0 B

compressed-size-action

Copy link
Contributor

@BrittanyIRL BrittanyIRL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this alot! Several v small suggestions - tested in firefox, chrome, safari with mouse, keyboard and voice over.

I also thought this was odd in Safari?
odd safari shapes

<Label key={direction} htmlFor={direction} direction={direction}>
<HiddenCaption>
{sprintf(
/* translators: %s: story title. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: think ya mean which direction not story title?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol. yeaup

<RadioGroup>
{directions.map((direction) => (
<Label key={direction} htmlFor={direction} direction={direction}>
<HiddenCaption>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this span is hidden and only serving to indicate to screen readers what the labeling is, you're better off using aria-label on the Label and removing HiddenCaption.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooo this is the magic I was looking for. thanks!

{sprintf(
/* translators: %s: story title. */
__('%s Direction', 'web-stories'),
direction.replace(/([a-z])([A-Z])/g, '$1 $2')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is resulting in: bottom To Top Direction casing. Feel like the first word should also be capitalized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. will update

Comment on lines 136 to 138
input:focus ~ ${DirectionIndicator} {
outline: 5px auto -webkit-focus-ring-color;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't showing an outline on firefox?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out, will trouble shoot

Copy link
Contributor

@mariano-formidable mariano-formidable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking great, but I noticed one little bug. When I first load up storybook, even though the default value is set to TOP_TO_BOTTOM, the component renders as if nothing is selected:
image

@littlemilkstudio
Copy link
Contributor Author

It's looking great, but I noticed one little bug. When I first load up storybook, even though the default value is set to TOP_TO_BOTTOM, the component renders as if nothing is selected:
image

Ahh good catch. updated the prop from defaultValue to defaultChecked in the component and forgot to update the storybook story for it

@codecov
Copy link

codecov bot commented Aug 21, 2020

Codecov Report

Merging #4143 into main will increase coverage by 12.83%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #4143       +/-   ##
===========================================
+ Coverage   69.63%   82.46%   +12.83%     
===========================================
  Files         792      812       +20     
  Lines       13913    14146      +233     
===========================================
+ Hits         9688    11666     +1978     
+ Misses       4225     2480     -1745     
Flag Coverage 螖
#karmatests 70.00% <酶> (+40.91%) 猬嗭笍
#unittests 65.63% <100.00%> (+0.08%) 猬嗭笍

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage 螖
assets/src/animation/constants.js 100.00% <酶> (酶)
assets/src/edit-story/theme.js 87.50% <酶> (+62.50%) 猬嗭笍
...components/panels/animation/directionRadioInput.js 100.00% <100.00%> (酶)
...-story/app/story/useStoryReducer/reducers/utils.js 69.69% <0.00%> (-30.31%) 猬囷笍
...ts/src/dashboard/app/views/editorSettings/index.js 71.87% <0.00%> (-28.13%) 猬囷笍
assets/src/animation/parts/index.js 35.29% <0.00%> (-14.71%) 猬囷笍
.../src/dashboard/app/views/shared/typeaheadSearch.js 85.71% <0.00%> (-14.29%) 猬囷笍
assets/src/dashboard/app/api/useSettingsApi.js 70.83% <0.00%> (-10.42%) 猬囷笍
...p/story/useStoryReducer/reducers/deleteElements.js 96.42% <0.00%> (-3.58%) 猬囷笍
assets/src/dashboard/app/views/toaster/index.js 75.00% <0.00%> (-1.93%) 猬囷笍
... and 204 more

<Label
key={direction}
aria-label={sprintf(
/* translators: %s: which direction. */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe give an example? e.g.

Suggested change
/* translators: %s: which direction. */
/* translators: %s: Direction, for example 'top' or 'left'. */

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it looks like direction will bee something like rightToLeft, and then you are transforming this to right-to-left? But right-to-left cannot really be translated? 馃

I would change this to:

__( 'Direction: %s', 'web-stories' ) and then you'll need to make all the directions translatable, e.g. __('right-to-left'), etc. And no, __(direction) doesn't work :-)

Hope that makes sense.

const camelToPascal = (string) =>
string.charAt(0).toUpperCase() + string.slice(1);

const pascalToSentance = (string) => string.replace(/([a-z])([A-Z])/g, '$1 $2');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/sentance/sentence

Copy link
Contributor

@BrittanyIRL BrittanyIRL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!
The issue I was seeing with the outline on firefox is resolved and there's no weirdly shaped outline on safari.

Copy link
Contributor

@mariano-formidable mariano-formidable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!!!

@littlemilkstudio littlemilkstudio merged commit d541092 into main Aug 21, 2020
@littlemilkstudio littlemilkstudio deleted the 3794-animation-panel-direction-ui branch August 21, 2020 19:53
@swissspidy
Copy link
Collaborator

@littlemilkstudio My comment doesn鈥榯 seem to have been fully addressed? Can you please open a follow-up ticket to make the directions fully translatable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group: Animations Type: Enhancement New feature or improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Effect Panel - Direction UI Component
4 participants