Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Fix VIconButton default variant #1255

Merged
merged 5 commits into from
Apr 22, 2022
Merged

Conversation

sarayourfriend
Copy link
Contributor

@sarayourfriend sarayourfriend commented Apr 11, 2022

Fixes

Fixes #1206 by @zackkrida

Description

Fixes the problem in the linked issue by fixing the root cause in the VIconButton component. Also does some TypeScript stuff to make the VButton easier to use with TypeScript and able to type things like VIconButton that "spread props" to VButton.

Testing Instructions

Check out the VIconButton implementations in the app and ensure they look good:

  • PlayPause button
  • Content report form close button
  • License explanation tooltip in the filter list
  • Global audio player close button

I could add visual-regression tests for each of these but in the interest of expediency I only added it for the particular button in question.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend requested a review from a team as a code owner April 11, 2022 17:05
@sarayourfriend sarayourfriend requested review from krysal and obulat April 11, 2022 17:05
@openverse-bot openverse-bot added 🕹 aspect: interface Concerns end-users' experience with the software 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents labels Apr 11, 2022
@@ -95,7 +101,7 @@ const VButton = defineComponent({
as: {
type: String as PropType<ButtonForm>,
default: 'button',
validate: (val: ButtonForm) => buttonForms.includes(val),
validate: (val: unknown) => buttonForms.includes(val as ButtonForm),
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I only changed this because I was trying to get the ExtractPropTypes to work correctly with props that have default values. I'll set it back, there's no functional or operational difference either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Though the unknown parameter type is technically more correct).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It just doesn't matter because we don't call validate directly so the type checking in this function is basically a "whatever" kind of thing.

@@ -36,22 +36,20 @@ export default defineComponent({
* the current play status of the audio
*/
status: {
type: String,
validator: (val) => ['playing', 'paused', 'played'].includes(val),
type: String as PropType<'playing' | 'paused' | 'played'>,
Copy link
Contributor

Choose a reason for hiding this comment

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

We could use the type from active media store here:

type MediaStatus = 'ejected' | 'playing' | 'paused' // 'ejected' means player is closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a different status, this one has "played" instead of "ejected". IIRC there is some distinction, perhaps one for when the player is closed ("ejected") and the other for when the audio has simply finished playing to the end (in which case we show the replay button).

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, thank you for explaining :)

@sarayourfriend sarayourfriend force-pushed the fix/report-form-close-button branch from 83e0fe1 to 9de8a8e Compare April 14, 2022 09:36
Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

The buttons' colors are fixed. There are some size inconsistencies with the mockups:

The close button on the License Popover is the correct size (40x40px), but it probably should be right at the top of the popover (without any padding/margin).
The close button on the content report form is too big (48x48 instead of 40x40)

Do you think we should open a new issue for that?

@sarayourfriend
Copy link
Contributor Author

@obulat I can fix those here.

For the button position, I moved it because it looked awkward and wrong for it to not be vertically aligned with header text of the popover. cc @panchovm on that one.

@fcoveram
Copy link

In both the license Popover and the content report form, I see 48px as size for the button element. Is that for a reason? I am using a 24px size in the mockups to match other similar buttons.

Regarding the close button position in popovers, I have pending reviewing the popover style. Some cases have more content than others, and the vertical alignment can blend with the popover's title area. Here is an example.

CleanShot 2022-04-14 at 14 19 05@2x

For now, I would keep it top-right aligned with a top and right margin of 8px.

Also, notice that the resting style of the close button is dark-charcoal instead of dark-charcoal-70. I can create a ticket to add the state styles that interactive components have.

@obulat
Copy link
Contributor

obulat commented Apr 15, 2022

I think that the close buttons should be at least 40x40px, because on the mobile phones it's very difficult to click on buttons that are smaller than 40px. This is also an accessibility/SEO requirement that is checked by Google Lighthouse.
If you have a margin of 8px, the 24x24px button looks like it's a 40x40px button. We can have a button that is 40x40px right in the corner of the popover, that looks exactly as the designs, don't you think, @panchovm ?

@sarayourfriend sarayourfriend force-pushed the fix/report-form-close-button branch 3 times, most recently from 63c6952 to eb59273 Compare April 15, 2022 08:22
Copy link
Member

@krysal krysal left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +68 to +70
export type ButtonProps = ProperlyExtractPropTypes<
NonNullable<typeof VButton['props']>
>
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be after the declaration of VButton?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't decide 😅 I thought putting it before would make it more obvious where it was coming from for someone reading this and wondering how it worked 🤔 type declarations and references can appear in any order in a file so it doesn't cause any integrity issues.

@fcoveram
Copy link

The target size criterion requires a 48px size, but that is for AAA level. For AA it seems not necessary. Nonetheless, you are right about the size being too small. We already have a close component that has a 32px for the smallest size. We might go with that.

What do you think?

@sarayourfriend sarayourfriend force-pushed the fix/report-form-close-button branch from eb59273 to dadebee Compare April 22, 2022 12:45
@sarayourfriend sarayourfriend merged commit cca06e9 into main Apr 22, 2022
@sarayourfriend sarayourfriend deleted the fix/report-form-close-button branch April 22, 2022 13:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🕹 aspect: interface Concerns end-users' experience with the software 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect styles on reporting form close button
5 participants