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

createStyleSheet.createCSSRule #12

Open
lindelwa122 opened this issue Sep 28, 2023 · 0 comments
Open

createStyleSheet.createCSSRule #12

lindelwa122 opened this issue Sep 28, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers to do Feature is required

Comments

@lindelwa122
Copy link
Owner

createStyleSheet.createCSSRule

createStyleSheet

The createStyleSheet module facilitates the creation and application of CSS styles to elements. It's important to note that this module isn't intended to replace traditional CSS, but rather to provide an API for efficiently adding CSS rules to elements using JavaScript when it's the most suitable approach.

createCSSRule

Parameters/Inputs:

  • rules: object
  • save: boolean (optional)

The createStyleSheet module contains a private array named CSSRule. If save is set to true (which is the default behaviour), the function will push the provided rules to CSSRule. If save is set to false, it will not.

The function should iterate through the keys and values of the rules object. Each key represents a selector, and the corresponding value represents a declaration. For each selector and declaration, the function should invoke addStyle(selector, declaration).

For handling states and media queries, other functions like createMediaQueryRule and configureStateRule should be utilized to handle the job.

Here's an example of how the function should operate:

import { createStyleSheet } from '@dom-manipulation-library/dml'

createStyleSheet.createCSSRule({
   'body': {
       color: '#f8f8f8',
       backgroundColor: '#0fa',
   },

   '#main > .content': {
       overflow: 'hidden',
   },
});
@lindelwa122 lindelwa122 added enhancement New feature or request good first issue Good for newcomers to do Feature is required labels Sep 28, 2023
@lindelwa122 lindelwa122 self-assigned this Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers to do Feature is required
Projects
None yet
Development

No branches or pull requests

1 participant