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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📖 [amp-social-share][storybook][preact] Add basic bento storybook story for amp-social-share component #27745

Merged
merged 2 commits into from
Apr 23, 2020

Conversation

krdwan
Copy link
Contributor

@krdwan krdwan commented Apr 14, 2020

Add basic storybook story for amp-social-share component

Includes a change to preact amp-social-share file to include aria-label attribute. (This is used for accessibility, and without the label an accessibility error is triggered in storybook.)

aria-label is used for screenreaders


My understanding of bento is limited so please feel free to recommend changes

@krdwan
Copy link
Contributor Author

krdwan commented Apr 14, 2020

@caroqliu Would you mind giving this a quick review to make sure I am using social-share correctly in the context of bento? Thanks in advance!

@caroqliu caroqliu self-requested a review April 14, 2020 17:05
Copy link
Contributor

@caroqliu caroqliu left a comment

Choose a reason for hiding this comment

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

This looks good so far in terms of elaborating all of the pre-configurable providers for amp-social-share. Could you also include a knob for specifying an arbitrary href prop and logo for non-configured-providers?

cc @wassgha Is it possible yet to pass in children props? This could be helpful for the non-configured case above when publishers want to pass in custom logos to social share.

@wassgha
Copy link
Contributor

wassgha commented Apr 15, 2020

Yup! @krdwan do you need help making that example?

@krdwan
Copy link
Contributor Author

krdwan commented Apr 15, 2020

This looks good so far in terms of elaborating all of the pre-configurable providers for amp-social-share. Could you also include a knob for specifying an arbitrary href prop and logo for non-configured-providers?

cc @wassgha Is it possible yet to pass in children props? This could be helpful for the non-configured case above when publishers want to pass in custom logos to social share.

Thanks for the feedback @caroqliu. I'll look into the non-configured-providers and follow up on the next commit.

@krdwan
Copy link
Contributor Author

krdwan commented Apr 15, 2020

Yup! @krdwan do you need help making that example?

@wassgha Thanks, I'm not sure yet, let me look into it and I'll follow up if I need some help, thanks in advance! :)

@krdwan
Copy link
Contributor Author

krdwan commented Apr 16, 2020

This looks good so far in terms of elaborating all of the pre-configurable providers for amp-social-share. Could you also include a knob for specifying an arbitrary href prop and logo for non-configured-providers?
cc @wassgha Is it possible yet to pass in children props? This could be helpful for the non-configured case above when publishers want to pass in custom logos to social share.

Thanks for the feedback @caroqliu. I'll look into the non-configured-providers and follow up on the next commit.

@caroqliu Please see latest changes, I added a knob to specify a custom href prop. From my understanding, the preact version of the component cannot customize the logo via props (it has to rely on the type prop which picks from the pre-defined logos). Can you let me know if this is incorrect?

Copy link
Contributor

@caroqliu caroqliu left a comment

Choose a reason for hiding this comment

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

Thanks for the modifications, Kevin. Could we also add a storybook sample for AMP mode in addition to Preact mode? This can help us directly compare how significant the differences in usage is between the modes, and more tangibly how to close this gap smoothly.

'line',
'sms',
'system',
'custom endpoint',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to create an input for type that's outside of the preconfigured providers? i.e. a select dropdown of preconfigured providers or an empty input to configure the type prop value, since really publishers can put anything they want, not just "custom endpoint".

Copy link
Contributor Author

@krdwan krdwan Apr 21, 2020

Choose a reason for hiding this comment

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

It is possible, but any 'type' attribute that is not one of the pre-configured types, actually does not change the behavior of the component. So having the 'custom endpoint' as a catch all should address this use case. Unless there is something else I'm missing.

Copy link
Contributor

Choose a reason for hiding this comment

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

@caroqliu could you clarify? It also looks to me that a single "custom endpoint" should suffice. Do you see the need for more?

Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to consider my suggestion as optional. I am asking for the freeform input knob for the sake of completeness of the possible publisher-facing experience. It's true that technically the "custom endpoint" option covers that codepath.

@krdwan
Copy link
Contributor Author

krdwan commented Apr 21, 2020

Thanks for feedback @dvoytenko @caroqliu . Based on discussions from last week and comments above, it sounds like we want to re-design the preact version of this component. Since this PR is dependent on the final behavior of the re-designed component, I will hold off on making any additional changes here.

To help with comparing the behavior, I have created a PR to add stories for the amp version of the component, which can be found here: #27906

For reference, the current state behavior is such --

  • In amp mode, the 'type' attribute maps to a share-end-point and also some default parameters. These are defined in amp-social-share-config.js. The user only has to specify the 'type' and component logic handles the rest.
  • In preact mode, there is no logic to access this end-point so the user has to manually provide it and pass it into the component. Default parameters from the config file are also not accessed so any parameters like 'url to be shared', 'title', 'text', etc... have to be manually provided by the user.

@dvoytenko
Copy link
Contributor

@krdwan It sounds like we want to change how Preact component works. And the good time to do it is essentially now. Let's complete this story book as a highlight what we want to change and then start addressing this issues in the follow up pull requests. But I agree with @caroqliu - let's add AMP storybook as well right away. I'd really like to see them side-by-side - that will help us design the right APIs for both.

@krdwan
Copy link
Contributor Author

krdwan commented Apr 22, 2020

@krdwan It sounds like we want to change how Preact component works. And the good time to do it is essentially now. Let's complete this story book as a highlight what we want to change and then start addressing this issues in the follow up pull requests. But I agree with @caroqliu - let's add AMP storybook as well right away. I'd really like to see them side-by-side - that will help us design the right APIs for both.

@dvoytenko Sounds good, I am onboard with merging this story and the amp version story so we can compare side by side. Once everyone has a chance to play around with it in storybook, I am happy to make further updates.

I am currently now allowed to merge so if someone wants to merge for me please do :)

Also the amp version story is in review, if anyone wants to review / approve it please do :)
#27906

cc: @caroqliu @wassgha

@@ -83,6 +83,7 @@ export function SocialShare(props) {
onClick={handleActivation}
style={{...size, ...props['style']}}
{...props}
aria-label={`amp-social-share component of type: ${type}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably make this a bit more user-friendly along the lines of 'Share on ${type}' ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, certainly. It's a user-readable string.

@caroqliu caroqliu merged commit 07a31c6 into ampproject:master Apr 23, 2020
ldoroshe pushed a commit to ldoroshe/amphtml that referenced this pull request May 8, 2020
…hare component (ampproject#27745)

* Basic bento story for amp-social-share component

* Update amp-social-share story to allow custom endpoint
@krdwan krdwan changed the title 📖 [amp-social-share] Add basic bento storybook story for amp-social-share component 📖 [storybook][amp-social-share][preact] Add basic bento storybook story for amp-social-share component May 14, 2020
@krdwan krdwan changed the title 📖 [storybook][amp-social-share][preact] Add basic bento storybook story for amp-social-share component 📖 [amp-social-share][storybook][preact] Add basic bento storybook story for amp-social-share component May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants