Skip to content

Add scss for direct use in the Chameleon skin.#27

Closed
WouterRademaker wants to merge 1 commit into
ProfessionalWiki:masterfrom
WouterRademaker:scss
Closed

Add scss for direct use in the Chameleon skin.#27
WouterRademaker wants to merge 1 commit into
ProfessionalWiki:masterfrom
WouterRademaker:scss

Conversation

@WouterRademaker

@WouterRademaker WouterRademaker commented Feb 27, 2025

Copy link
Copy Markdown
Contributor

If we want to use the font files from this extension in the Chameleon skin, instead of its ‘own’ font files, we also need the scss files here. See Chameleon#458

Summary by CodeRabbit

  • New Features
    • Updated the build process to include expanded SCSS styling assets for enhanced icon presentation.
    • Introduced customizable styling options, offering a range of effects such as animations, rotations, flipping, stacking, scalable sizing, and fixed-width presentation.
    • Improved accessibility with utilities that respect user motion preferences.
    • Extended support for varied icon sets—including brand, regular, solid, and legacy versions—providing broader visual integration.

@coderabbitai

coderabbitai Bot commented Feb 27, 2025

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request updates the build script in the project’s package.json to include the SCSS directory when copying Font Awesome resources. Additionally, it introduces a broad set of new SCSS files for Font Awesome Free v6.7.2. These SCSS modules define new classes, functions, mixins, and keyframe animations; set up base and style-specific font-face rules; and provide layout, sizing, accessibility, and legacy compatibility (V4 shims). The change modularizes and expands the available styling and functionality components for Font Awesome.

Changes

File(s) Change Summary
package.json Updated the build:fontawesome script to copy the additional SCSS directory along with the existing css, js, webfonts, and LICENSE file.
res/fontawesome/scss/_*.scss
(animated, bordered-pulled, core, fixed-width, functions, icons, list, mixins, rotated-flipped, screen-reader, shims, sizing, stacked)
Introduced new SCSS modules that add classes, functions, mixins, and keyframe definitions for animations, base icon styling, fixed width layouts, list formatting, rotations/flips, accessibility, sizing, stacking, and legacy shims.
res/fontawesome/scss/{brands,fontawesome,regular,solid,v4-shims}.scss Added core SCSS files for Font Awesome Free v6.7.2, setting up font-face rules, CSS custom properties, imports of utility modules, and compiling style-specific outputs (brands, regular, solid) as well as V4 compatibility shims.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
package.json (1)

3-4: Consider cross-platform compatibility.
Since the command uses a bash -c invocation, this may not run smoothly on Windows environments by default. Consider using a Node-based alternative or a cross-platform tool (e.g., rimraf) to improve portability.

res/fontawesome/scss/_mixins.scss (1)

16-20: Font Sizing and Alignment Mixin (fa-size)
The mixin uses helper functions such as fa-divide to compute relative sizing and vertical alignment.
Note: The inline comment uses "it's parent" – consider changing to "its parent" for grammatical accuracy.

res/fontawesome/scss/_shims.scss (1)

101-1579: Overall Assessment of the Icon Shim File
The _shims.scss file covers an extensive set of Font Awesome icons. The consistent structure and interpolation tactics make it reliable; however, given its length and repetitive nature, automating generation via SCSS maps and loops may enhance maintainability. If this file is generated by a script, be sure to document the generation process so that future maintainers know how to update or re-generate it.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f981435 and 8254f7e.

📒 Files selected for processing (19)
  • package.json (1 hunks)
  • res/fontawesome/scss/_animated.scss (1 hunks)
  • res/fontawesome/scss/_bordered-pulled.scss (1 hunks)
  • res/fontawesome/scss/_core.scss (1 hunks)
  • res/fontawesome/scss/_fixed-width.scss (1 hunks)
  • res/fontawesome/scss/_functions.scss (1 hunks)
  • res/fontawesome/scss/_icons.scss (1 hunks)
  • res/fontawesome/scss/_list.scss (1 hunks)
  • res/fontawesome/scss/_mixins.scss (1 hunks)
  • res/fontawesome/scss/_rotated-flipped.scss (1 hunks)
  • res/fontawesome/scss/_screen-reader.scss (1 hunks)
  • res/fontawesome/scss/_shims.scss (1 hunks)
  • res/fontawesome/scss/_sizing.scss (1 hunks)
  • res/fontawesome/scss/_stacked.scss (1 hunks)
  • res/fontawesome/scss/brands.scss (1 hunks)
  • res/fontawesome/scss/fontawesome.scss (1 hunks)
  • res/fontawesome/scss/regular.scss (1 hunks)
  • res/fontawesome/scss/solid.scss (1 hunks)
  • res/fontawesome/scss/v4-shims.scss (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • res/fontawesome/scss/_fixed-width.scss
  • res/fontawesome/scss/fontawesome.scss
  • res/fontawesome/scss/v4-shims.scss
  • res/fontawesome/scss/regular.scss
  • res/fontawesome/scss/solid.scss
🔇 Additional comments (67)
res/fontawesome/scss/_sizing.scss (3)

1-3: Clean header and file structure.
The introductory comments clearly state that this file manages sizing for Font Awesome icons.


4-9: Efficient literal magnification scale generation.
The @for loop elegantly creates classes for sizes 1x to 10x by multiplying the base unit.


11-16: Clear step-based scale implementation.
Using the @each loop over the $fa-sizes map with the fa-size mixin ensures modularity and flexibility in sizing.

res/fontawesome/scss/_icons.scss (3)

1-3: Descriptive file header and comments.
The header comments effectively explain the purpose of the file and the use of Font Awesome’s Unicode Private Use Area.


4-6: Well-articulated explanation on Unicode usage.
The multi-line comment clarifies why the Unicode Private Use Area is used, aiding accessibility by preventing misinterpretation by screen readers.


7-11: Dynamic icon class generation is implemented correctly.
The @each loop produces CSS classes dynamically for each icon in $fa-icons, and the use of unquote ensures proper formatting for Unicode values.

package.json (1)

3-4: Build script updated to include SCSS resources.
The build:fontawesome command now copies the scss directory along with other assets, ensuring the new SCSS files are part of the build output.

res/fontawesome/scss/_list.scss (3)

1-3: Clear introductory comments.
The file header concisely indicates that the styles are for icons in a list, which aids in quick identification of its purpose.


4-10: Solid definition for list container styling.
The .#{$fa-css-prefix}-ul class resets list style properties and sets up a proper structure by handling margin and padding, including nesting child li elements.


12-18: Appropriate list item styling.
The .#{$fa-css-prefix}-li class leverages CSS variables to manage positioning and width with clarity, ensuring consistent layout.

res/fontawesome/scss/_screen-reader.scss (3)

1-3: Clear labeling of screen reader utility styles.
The header comments explicitly state that the file contains utilities that enhance accessibility for screen readers.


4-8: Effective implementation of visually hidden content.
Applying the fa-sr-only mixin to both the .sr-only and its prefixed variant properly hides content from visual display while keeping it accessible to screen readers.


10-14: Well-implemented focusable enhancements for accessibility.
The .sr-only-focusable classes correctly invoke the fa-sr-only-focusable mixin, enabling content to appear when focused, which improves navigability for keyboard users.

res/fontawesome/scss/_bordered-pulled.scss (4)

1-3: Section Header and Comments.
The initial comments clearly label the section for bordered and pulled icons, providing a helpful overview.


4-10: Bordered Icon Styles.
The .#{$fa-css-prefix}-border class uses well-defined CSS variables with appropriate fallback values to set border properties and padding. This modular approach ensures ease of customization.


12-15: Pull-Left Icon Styling.
The .#{$fa-css-prefix}-pull-left class correctly applies float: left with a variable for the right margin for proper spacing.


17-20: Pull-Right Icon Styling.
The .#{$fa-css-prefix}-pull-right class mirrors the pull-left approach by using float: right and an analogous margin variable, ensuring consistency.

res/fontawesome/scss/brands.scss (6)

1-5: License and Metadata.
The header comment block properly documents the version, license, and copyright details for Font Awesome Free 6.7.2.


6-8: Module Imports.
The file imports the functions and variables modules, setting up the necessary foundation for the SCSS definitions that follow.


9-12: Custom Properties Definition.
The :root, :host block defines custom properties for brand-related styles, ensuring that the font and style family are easily configurable.


14-21: Font Face Declaration.
The @font-face block correctly declares the 'Font Awesome 6 Brands' font, including style, weight, display options, and sources for both woff2 and truetype formats.


23-26: Brand Classes Font Weight.
Both the .fab and .#{$fa-css-prefix}-brands classes are set to a font weight of 400, which aligns well with common usage for brand icons.


28-30: Dynamic Brand Icon Classes.
The @each loop dynamically generates classes for each brand icon by applying the relevant CSS property. This approach efficiently scales the styling as new icons are added.

res/fontawesome/scss/_stacked.scss (6)

1-3: Stacking Icons Section Header.
The initial comments and separator provide clear context that the following styles pertain to stacking icons, aiding readability.


4-11: Stack Container Definition.
The .#{$fa-css-prefix}-stack class is well-defined with an inline-block display, explicit height, and relative positioning. Variables for vertical alignment and width ensure that the container adapts to different contexts.


13-20: Stacked Elements Styling.
The grouped selectors for .#{$fa-css-prefix}-stack-1x and .#{$fa-css-prefix}-stack-2x appropriately use absolute positioning, full width, and center alignment. The use of a variable for z-index further supports customization of layering.


22-24: Stack-1x Inheritance.
Applying line-height: inherit to the .#{$fa-css-prefix}-stack-1x class ensures consistent vertical spacing derived from the container.


26-28: Stack-2x Scaling.
The .#{$fa-css-prefix}-stack-2x class increases the font size to 2em, effectively scaling the icon while maintaining the overall alignment within the stack.


30-32: Inverse Color Class.
The .#{$fa-css-prefix}-inverse class leverages a custom property to apply a contrasting color, enhancing visual versatility for icons against varying backgrounds.

res/fontawesome/scss/_functions.scss (4)

1-3: Functions Section Header.
The initial comment block clearly identifies this as the functions section, setting the stage for the utility functions that follow.


4-7: fa-content Function.
The fa-content function effectively transforms a variable into an unquoted string for CSS content properties, ensuring correct rendering in styles.


9-33: License Attribution for fa-divide.
The detailed license and attribution comments for the code borrowed from Bootstrap are essential to maintain compliance with licensing requirements.


39-57: fa-divide Function: Division Logic.
The remaining division logic—using a while loop to compute the quotient and recursion for precision—is well-structured. Ensure thorough testing with various dividend/divisor pairs (including negatives and zero values) to validate its robustness.

res/fontawesome/scss/_rotated-flipped.scss (8)

1-3: Rotated and Flipped Icons Section Header.
The opening comments succinctly indicate that the file contains styles for rotating and flipping icons, promoting easy navigation.


4-6: Rotate 90 Degrees.
The class .#{$fa-css-prefix}-rotate-90 applies a 90-degree rotation correctly using the CSS transform property.


8-10: Rotate 180 Degrees.
The .#{$fa-css-prefix}-rotate-180 class is implemented correctly, applying a 180deg rotation with clear and concise CSS.


12-14: Rotate 270 Degrees.
The .#{$fa-css-prefix}-rotate-270 class applies the proper 270-degree rotation through the transform property.


16-18: Flip Horizontal.
The horizontal flipping is straightforwardly implemented with transform: scale(-1, 1), achieving the desired reflection effect.


20-22: Flip Vertical.
Similarly, the vertical flip uses scale(1, -1) correctly, inverting the icon along the vertical axis.


24-27: Flip Both Directions.
The combined class for flipping both horizontally and vertically—with an alternative selector combining separate flip classes—ensures that icons can easily be inverted along both axes simultaneously.


29-31: Dynamic Rotation.
The .#{$fa-css-prefix}-rotate-by class allows the icon's rotation angle to be dynamically set via a CSS custom property, adding flexible, on-the-fly control over rotation.

res/fontawesome/scss/_core.scss (6)

1-3: Overall Structure and Comments
The file is newly introduced and clearly structured. The header comments separating sections provide a good visual cue for maintainability.


4-7: Base Icon Class Definition
The declaration for the interpolated base icon class (using .#{$fa-css-prefix}) correctly sets up the font family and weight based on CSS variables. This provides a flexible way to configure the icon styles.


9-23: Grouping of Icon Classes with Common Styling
The grouped selectors for .fas, .far, .fab, and the interpolated classes (e.g. .#{$fa-css-prefix}-solid) properly apply font smoothing, display, and text-rendering properties. This grouping maintains consistency across different icon variants.


25-33: Pseudo-element Content via CSS Variables
Defining the ::before pseudo-element to pull its content from a CSS variable (var(#{$fa-icon-property})) is a neat approach that allows dynamic updates.


35-45: Font-Family Assignment for Variants
The explicit assignment of the font-family for the classic (free) and brand icons is clear and adheres to Font Awesome conventions.


47-49: Placeholder for Icon Styling
The placeholder %fa-icon is concise and delegates to the fa-icon mixin, ensuring reuse of base icon styling.

res/fontawesome/scss/_mixins.scss (6)

1-3: File Header and Organizational Comments
The header and divider comments clearly delineate the mixin sections. This aids in readability, especially for new contributors.


5-13: Base Rendering Mixin (fa-icon)
The mixin correctly applies antialiased font smoothing, inline display, and resets font style/variant and line-height. This is essential for ensuring consistency across icon implementations.


25-35: Screen Reader Only Mixin (fa-sr-only)
This mixin uses a well‐known pattern to hide content visually while keeping it accessible. The links to accessibility resources add useful context.


38-42: Focusable Screen Reader Mixin (fa-sr-only-focusable)
The mixin appropriately includes fa-sr-only when an element is not focused, ensuring accessibility for keyboard users.


45-47: Icon Family Extension Mixin (fa-family-classic)
Using @extend to include the classic family is a simple and effective approach.


51-65: Convenience Mixins for Icon Pseudo-elements
The mixins fa-icon-solid, fa-icon-regular, and fa-icon-brands correctly extend their respective Font Awesome classes and assign the icon content using CSS variable interpolation and unquote(). This design supports both the normal and duotone icon usages.

res/fontawesome/scss/_animated.scss (12)

1-3: File Organization and Overview
The animation file is clearly organized with header comments. The separation between the animation classes and keyframe definitions makes the file easy to navigate.


4-11: Animation Class: Beat
The .#{$fa-css-prefix}-beat class correctly applies animation properties using CSS variables for delay, duration, and timing. The use of the interpolated keyframe name ensures consistency with other parts of the framework.


13-20: Animation Class: Bounce
Similarly, the bounce animation class is well-defined, with a customized cubic-bezier easing function to achieve the desired dynamic effect.


22-29: Animation Class: Fade
The fade animation uses a cubic-bezier timing function that appears to be tuned for a smooth fade transition.


31-38: Animation Class: Beat-Fade
The .#{$fa-css-prefix}-beat-fade class mirrors the beat animation but with modified timing for opacity changes and scale. This adds a nice variation for icon animations.


40-47: Animation Class: Flip
The flip animation is defined with the appropriate properties. Using interpolation for the animation name and CSS variables for delay and duration ensures flexibility.


49-56: Animation Class: Shake
The shake animation uses a linear timing function which is appropriate for a shaking effect. The consistent application of CSS variables standardizes timing across animations.


58-65: Animation Class: Spin
Defining the spin animation with a duration of 2s (different from the others) is a deliberate design choice to slow down the rotation. Overall, the properties are well-organized.


67-69: Animation Class: Spin-Reverse
Overriding the animation direction with a custom property for the reverse spin is a clever use of CSS variables.


71-78: Animation Classes: Pulse & Spin-Pulse
Both pulse and spin-pulse reuse the spin animation with a modified timing function (using steps(8)), which is a good strategy for achieving a pulsating effect.


80-99: Accessibility: Reduced Motion Support
The media query for (prefers-reduced-motion: reduce) appropriately disables animations for users with motion sensitivities by significantly shortening durations and iteration counts. The inclusion of reference links is an excellent practice.


101-153: Keyframe Definitions for Animations
All keyframe animations (beat, bounce, fade, beat-fade, flip, shake, and spin) are defined using interpolation and CSS variables. The keyframes cover the necessary transformation states and are consistent with the animation classes defined earlier.

res/fontawesome/scss/_shims.scss (2)

1-10: Comprehensive Icon Shim Definitions (Part 1)
The file defines a wide range of CSS classes for mapping Font Awesome icon names to their corresponding CSS variable values. The use of interpolation in selectors (e.g. .#{$fa-css-prefix}.#{$fa-css-prefix}-glass) and in the unquote() function for the icon content is consistent and effective.


11-40: Consistency in Icon Class Declarations (Part 2)
Throughout the file, each icon class is consistently defined with two parts: one block for setting font-family and font-weight (when needed) and a subsequent rule to assign the #{$fa-icon-property} using the associated variable (e.g. $fa-var-envelope). This pattern reinforces maintainability and clarity.

Comment on lines +34 to +38
@function fa-divide($dividend, $divisor, $precision: 10) {
$sign: if($dividend > 0 and $divisor > 0, 1, -1);
$dividend: abs($dividend);
$divisor: abs($divisor);
$quotient: 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

fa-divide Function: Sign Calculation Issue.
The sign determination in the fa-divide function (line 35) only checks if both $dividend and $divisor are positive, which will incorrectly assign a negative sign when both values are negative. This logic should be updated to handle all cases correctly. Consider revising using a multiplication check to determine the sign, for example:

-  $sign: if($dividend > 0 and $divisor > 0, 1, -1);
+  $sign: if($dividend * $divisor < 0, -1, 1);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@function fa-divide($dividend, $divisor, $precision: 10) {
$sign: if($dividend > 0 and $divisor > 0, 1, -1);
$dividend: abs($dividend);
$divisor: abs($divisor);
$quotient: 0;
@function fa-divide($dividend, $divisor, $precision: 10) {
$sign: if($dividend * $divisor < 0, -1, 1);
$dividend: abs($dividend);
$divisor: abs($divisor);
$quotient: 0;

@WouterRademaker

Copy link
Copy Markdown
Contributor Author

Got included in #37.

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.

1 participant