Integrate Common Styles File

The styles.scss file in this context is part of an Angular project that is utilizing a modular approach to styling by integrating a common styles library. This file serves as a central point for defining global styles that apply across the entire application, as well as importing additional style files that contain shared styles.

Overview

  • Global Styles: The file allows you to define styles that should be applied globally to the application. This is useful for setting base styles that ensure consistency across different components and pages.

  • Importing Common Styles: The @import statement is used to bring in styles from a shared library, common-styles.scss, which is located in a common styles library. This promotes reusability and maintainability by centralizing common styles that can be used across multiple projects or components.

  • HTML and Body Styling: The styles for html and body elements are set to occupy the full height and width of the viewport. This is a common practice to ensure that the application layout can be controlled more predictably, especially when using CSS frameworks or custom layouts that rely on full-page designs.

Why We Are Doing It

  • Consistency: By defining global styles and importing common styles, we ensure a consistent look and feel across the application. This reduces the need for repetitive styling in individual components.

  • Maintainability: Centralizing styles in a common library makes it easier to update and maintain them. Changes made in the common styles library will automatically propagate to all parts of the application that import these styles.

  • Scalability: As the application grows, having a structured approach to styling helps manage complexity. It allows developers to easily add new styles or modify existing ones without affecting unrelated parts of the application.

How It Works

  1. Global Styles Definition: You can add any global styles directly within this styles.scss file. These styles will be applied throughout the application, providing a base styling layer.

  2. Importing Styles: The @import directive is used to include styles from the common-styles.scss file. This file is part of a library that contains shared styles, which can include variables, mixins, and reusable CSS classes.

  3. HTML and Body Setup: By setting the html and body elements to 100% height and width, the application is prepared for layouts that require full-page designs. This is particularly useful for applications that need to support responsive designs or dynamic content that adjusts to the viewport size.

In summary, this file is a crucial part of the styling infrastructure in an Angular application, enabling efficient and scalable management of styles through the use of global definitions and shared libraries.

sass icon
styles.scss
/* You can add global styles to this file, and also import other style files */
@import "libs/common/styles/src/lib/common-styles.scss";

html, body {
  height: 100%;
  width: 100%;
}