Skip to content

Improve shape voiceover #136

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

Merged
merged 7 commits into from
Apr 8, 2022
Merged

Conversation

thekuoster
Copy link
Contributor

@thekuoster thekuoster commented Mar 11, 2022

Addresses #36

Summary

Updated the describe text for basic shapes and text to give more explanation. The generic Thing describe gives no information on sizing of shapes and other attributes other than type and color so subclasses need more explanation to get a full picture of what's there.

Changes:

  • Add radius to Circle describe
  • Add width and height to Rectangle describe
  • Add font to Text describe
  • Ensure that hex code is not interpreted as words

Screenshots of the change:

image
image

Checklist

  • npm test passes
  • Unit tests are included / updated
  • Documentation has been updated where relevant

Copy link
Contributor

@anderoonies anderoonies left a comment

Choose a reason for hiding this comment

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

Looks good to me, we probably want to add tests for these in the individal shapes' tests for making sure that the shape produces the description we expect

@@ -512,7 +512,7 @@ class Thing {
* Describes the element for use with screen readers.
*/
describe() {
return `A ${this.type} at ${this.x}, ${this.y}. Colored: ${this.color}.`;
return `A ${this.type} at ${this.x}, ${this.y}. Colored: ${this.color.toUpperCase()}.`;
Copy link
Contributor

Choose a reason for hiding this comment

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

How does toUpperCase() change the voiceover? Just curious

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'm not sure if this is the best fix, but if you use the voiceover for your example which has the color #560bad, it says the word "bad" when reading it. By adding the uppercase it reads each letter. I did notice that it does read #F72585 as "F seventy two thousand...," so I'm not sure how to fix that. The downside is that if you put in a color like white it comes out as WHITE. With the mac voiceover it still reads the word, but I think I read somewhere that different voiceovers might interpret that as "W...H...I...T...E". Think this would take more testing to figure out and we might end up wanting to write some sort of describe function for color.

Copy link
Contributor

Choose a reason for hiding this comment

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

interesting, i think that a describe function for color makes a lot of sense. ideally we'd be able to parse hex values and give them some sort of meaning ("red" instead of "#FF0000"), but that seems difficult.

alternatively we could move towards enforcing strings as colors instead of hex strings. all valid CSS colors are valid for the context, so you can say circle.color = 'red' or 'aqua' or whatever and it works.

as a strategy for naming colors, we could compute the distance to a named color, so #b30000 would have a distance of b8 - b3, 00 - 00, 00 - 00 from "dark red" #b80000

Copy link
Contributor

Choose a reason for hiding this comment

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

Here's a quick draft of that https://codehs.com/sandbox/andy/color-namer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is super cool. I wonder what other people do and what's actually the most useful. I think for beginners just using names makes a lot of sense, but at some point we may need/want to handle the ability to get the hex, rgba, and hsl values for a color.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think our HSL implementation and RGB -> hex in this library are broken, but we can definitely support those. I've been meaning to revisit Color soon.

@thekuoster
Copy link
Contributor Author

Looks good to me, we probably want to add tests for these in the individal shapes' tests for making sure that the shape produces the description we expect

Yah, didn't have time to look into that yet, but I'll look into putting those tests in.

@zgalant
Copy link
Member

zgalant commented Mar 11, 2022 via email

@thekuoster thekuoster force-pushed the improve-shape-voiceover branch from 5ef2c13 to a0ff041 Compare April 8, 2022 09:52
@anderoonies
Copy link
Contributor

This looks great, thanks for the tests. Merging it now, it will be in the next release!

@anderoonies anderoonies merged commit 114aa57 into codehs:main Apr 8, 2022
@anderoonies
Copy link
Contributor

@all-contributors please add @thekuoster for a11y and code

@allcontributors
Copy link
Contributor

@anderoonies

I've put up a pull request to add @thekuoster! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants