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

[Storybook] Configure Aphrodite to Not Append !important to Styles #2107

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

mark-fitzgerald
Copy link
Contributor

@mark-fitzgerald mark-fitzgerald commented Jan 14, 2025

Summary:

Aphrodite appends !important to all styling, by default. This is cumbersome for debugging and for writing appropriately defined rulesets. This configuration change causes Aphrodite to NOT append !important. This change is limited to our dev environments (i.e. Storybook). Webapp has already implemented this, and handles Perseus styling accordingly.

Additionally, this change uncovered a bug that causes an incorrect option to display as blue instead of red. The styling logic was refactored to account for the removal of !important and to clarify how styling is applied based upon the widget options.

Issue: LEMS-2227

Test plan:

  1. Open Storybook locally.
  2. Inspect any widget with the browser inspect tool.
  3. Note the significant lack of !important suffixes.

Test plan for bugfix:

  1. Open Storybook locally.
  2. Navigate to Perseus > Widgets > Radio > Choice > Review Mode
  3. Note that the third item ("Incorrect (selected)") is red, and not blue.

@mark-fitzgerald mark-fitzgerald self-assigned this Jan 14, 2025
Copy link
Contributor

github-actions bot commented Jan 14, 2025

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (ba8bb5a) and published it to npm. You
can install it using the tag PR2107.

Example:

yarn add @khanacademy/perseus@PR2107

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR2107

Copy link
Contributor

github-actions bot commented Jan 14, 2025

Size Change: +3 B (0%)

Total Size: 1.48 MB

Filename Size Change
packages/perseus/dist/es/index.js 382 kB +3 B (0%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 86.8 kB
packages/math-input/dist/es/index.js 77.6 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 43.5 kB
packages/perseus-editor/dist/es/index.js 688 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus-score/dist/es/index.js 113 kB
packages/perseus/dist/es/strings.js 5.82 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@mark-fitzgerald mark-fitzgerald marked this pull request as ready for review January 14, 2025 23:29
@mark-fitzgerald mark-fitzgerald requested a review from a team January 14, 2025 23:30
Comment on lines 9 to 10
// Once the LESS files have cascade layers included (a more involved task for a later time),
// then the following plugin option should be removed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for documenting the exit path. Do you think it's worth creating a ticket and noting it here?

Copy link
Member

Choose a reason for hiding this comment

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

I vote for a ticket created and linked here so we don't forget. 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@catandthemachines catandthemachines left a comment

Choose a reason for hiding this comment

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

Approved, added a note about linking a ticket for follow-up.

Comment on lines 9 to 10
// Once the LESS files have cascade layers included (a more involved task for a later time),
// then the following plugin option should be removed.
Copy link
Member

Choose a reason for hiding this comment

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

I vote for a ticket created and linked here so we don't forget. 😊

Mark Fitzgerald added 2 commits January 23, 2025 17:36
Adjust styling logic to use classes instead of inline styling.
// particular, at large zoom levels this line height does almost
// nothing, but at the default size this shifts the letter down one
// pixel so it is much better centered.
lineHeight: "1px",
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 doesn't appear to have any effect other than when isolated in a Storybook example. Removing it in an actual exercise has no effect.

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