Add scss for direct use in the Chameleon skin.#27
Conversation
📝 WalkthroughWalkthroughThis 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
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
package.json (1)
3-4: Consider cross-platform compatibility.
Since the command uses abash -cinvocation, 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 asfa-divideto 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.scssfile 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
📒 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@forloop elegantly creates classes for sizes 1x to 10x by multiplying the base unit.
11-16: Clear step-based scale implementation.
Using the@eachloop over the$fa-sizesmap with thefa-sizemixin 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@eachloop produces CSS classes dynamically for each icon in$fa-icons, and the use ofunquoteensures proper formatting for Unicode values.package.json (1)
3-4: Build script updated to include SCSS resources.
Thebuild:fontawesomecommand now copies thescssdirectory 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}-ulclass resets list style properties and sets up a proper structure by handling margin and padding, including nesting childlielements.
12-18: Appropriate list item styling.
The.#{$fa-css-prefix}-liclass 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 thefa-sr-onlymixin to both the.sr-onlyand 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-focusableclasses correctly invoke thefa-sr-only-focusablemixin, 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}-borderclass 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-leftclass correctly appliesfloat: leftwith a variable for the right margin for proper spacing.
17-20: Pull-Right Icon Styling.
The.#{$fa-css-prefix}-pull-rightclass mirrors the pull-left approach by usingfloat: rightand 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 thefunctionsandvariablesmodules, setting up the necessary foundation for the SCSS definitions that follow.
9-12: Custom Properties Definition.
The:root, :hostblock defines custom properties for brand-related styles, ensuring that the font and style family are easily configurable.
14-21: Font Face Declaration.
The@font-faceblock 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.faband.#{$fa-css-prefix}-brandsclasses are set to a font weight of 400, which aligns well with common usage for brand icons.
28-30: Dynamic Brand Icon Classes.
The@eachloop 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}-stackclass 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-1xand.#{$fa-css-prefix}-stack-2xappropriately 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.
Applyingline-height: inheritto the.#{$fa-css-prefix}-stack-1xclass ensures consistent vertical spacing derived from the container.
26-28: Stack-2x Scaling.
The.#{$fa-css-prefix}-stack-2xclass 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}-inverseclass 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.
Thefa-contentfunction 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-90applies a 90-degree rotation correctly using the CSStransformproperty.
8-10: Rotate 180 Degrees.
The.#{$fa-css-prefix}-rotate-180class is implemented correctly, applying a 180deg rotation with clear and concise CSS.
12-14: Rotate 270 Degrees.
The.#{$fa-css-prefix}-rotate-270class applies the proper 270-degree rotation through the transform property.
16-18: Flip Horizontal.
The horizontal flipping is straightforwardly implemented withtransform: scale(-1, 1), achieving the desired reflection effect.
20-22: Flip Vertical.
Similarly, the vertical flip usesscale(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-byclass 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::beforepseudo-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-iconis concise and delegates to thefa-iconmixin, 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 includesfa-sr-onlywhen an element is not focused, ensuring accessibility for keyboard users.
45-47: Icon Family Extension Mixin (fa-family-classic)
Using@extendto include the classic family is a simple and effective approach.
51-65: Convenience Mixins for Icon Pseudo-elements
The mixinsfa-icon-solid,fa-icon-regular, andfa-icon-brandscorrectly extend their respective Font Awesome classes and assign the icon content using CSS variable interpolation andunquote(). 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}-beatclass 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-fadeclass 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 (usingsteps(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 theunquote()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.
| @function fa-divide($dividend, $divisor, $precision: 10) { | ||
| $sign: if($dividend > 0 and $divisor > 0, 1, -1); | ||
| $dividend: abs($dividend); | ||
| $divisor: abs($divisor); | ||
| $quotient: 0; |
There was a problem hiding this comment.
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.
| @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; |
|
Got included in #37. |
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