learn suit: css naming convention

35
inarocket.com Learn at rocket speed SUIT CSS NAMING CONVENTION

Upload: in-a-rocket

Post on 21-Apr-2017

2.414 views

Category:

Internet


3 download

TRANSCRIPT

Page 1: Learn SUIT: CSS Naming Convention

inarocket.com

Learn at rocket speed

SUITCSS NAMING CONVENTION

Page 2: Learn SUIT: CSS Naming Convention

Learn front-end development at rocket speed

inarocket.com

by miguelsanchez.com

Page 3: Learn SUIT: CSS Naming Convention

in aROCKET

SUIT FUNDAMENTALSUnderstanding SUIT in just 2 minutes

Page 4: Learn SUIT: CSS Naming Convention

A BEM-based naming convention that helps to scope component CSS and make your widgets render more predictably.

LEARN SUIT: CSS naming conventions

+COMPONENTS UTILITIES

Developed by Nicholas Gallagher.

SUIT

SUIT comprises:

Page 5: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

+COMPONENTS UTILITIES

SUIT

Within components there can be Modifiers, Descendants and States.

A BEM-based naming convention that helps to scope component CSS and make your widgets render more predictably.

SUIT comprises:

Page 6: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT

Page 7: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT COMPONENT

DESCENDENT

DESCENDENT

DESCENDENT

DESCENDENT

A component descendent is a class that is attached to a descendent node of a component. It's responsible for applying presentation directly to the descendent on behalf of a particular component.

Page 8: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT COMPONENT

DESCENDENT

DESCENDENT

DESCENDENT

DESCENDENT

COMPONENT + MODIFIER

DESCENDENT

DESCENDENT

DESCENDENT

DESCENDENT

A component modifier is a class that modifies the presentation of the base component in some form.

Page 9: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT COMPONENT

DESCENDENT

DESCENDENT

DESCENDENT

DESCENDENT

COMPONENT + MODIFIER

DESCENDENT

DESCENDENT

DESCENDENT

DESCENDENT

COMPONENT + STATE

DESCENDENT

DESCENDENT

DESCENDENT

DESCENDENT

Use is-stateName to reflect changes to a component's state. Never style these classes directly; they should always be used as an adjoining class.

Page 10: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT COMPONENT

DESCENDENT

DESCENDENT

DESCENDENT

DESCENDENT

COMPONENT + MODIFIER

DESCENDENT

DESCENDENT

DESCENDENT

DESCENDENT

COMPONENT

DESCENDENT

DESCENDENT

DESCENDENT

DESCENDENT + STATE

Use is-stateName to reflect changes to a component's state. Never style these classes directly; they should always be used as an adjoining class.

Page 11: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

+COMPONENTS UTILITIES

SUIT

Utility classes map to fixed, low-level, structural and positional traits.

A BEM-based naming convention that helps to scope component CSS and make your widgets render more predictably.

SUIT comprises:

Page 12: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

Certain CSS properties and patterns are used frequently. For example: floats, containing floats, vertical alignment, text truncation.

Utilities: • can help to reduce repetition and provide

consistent implementations. • can be added to any element; multiple utilities

can be used together; and utilities can be used alongside component classes.

example.css

<div class="Tweet u-cf"> <a class="u-sizeFit" href="{{url}}"> <img class="u-block" src="{{src}}" alt=""> </a> <p class="Tweet-text u-sizeFill u-textBreak"> … </p></div>

UTILITIES

Utilities are grouped by type. The names of utilities with similar concerns usually start with a common string, e.g., u-textCenter, u-textTruncate; u-linkClean, u-linkBlock.

SOURCE: SUIT CSS - Utilities.

Page 13: Learn SUIT: CSS Naming Convention

in aROCKET

QUICK EXAMPLEHow it works with a real example

Page 14: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

$150 SUBSCRIBE NOW

Page 15: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT: MyBtn

Page 16: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT: MyBtn COMPONENT

$150 SUBSCRIBE NOW

DESCENDENT: price DESCENDENT: text

Page 17: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT: MyBtn COMPONENT

$150 SUBSCRIBE NOW

DESCENDENT: price DESCENDENT: text

COMPONENT + MODIFIER: important

$150 SUBSCRIBE NOW

Page 18: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT: MyBtn COMPONENT

$150 SUBSCRIBE NOW

DESCENDENT: price DESCENDENT: text

COMPONENT + MODIFIER: important

$150 SUBSCRIBE NOW $150 SUBSCRIBE NOW

COMPONENT + STATE: is-active

Page 19: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT: MyBtn COMPONENT

$150 SUBSCRIBE NOW

DESCENDENT: price DESCENDENT: text

COMPONENT + MODIFIER: important

$150 SUBSCRIBE NOW

COMPONENT

$150 SUBSCRIBE NOW

DESCENDENT + STATE: is-active

Page 20: Learn SUIT: CSS Naming Convention

in aROCKET

LET'S CODESUIT syntax you can start using right now

Page 21: Learn SUIT: CSS Naming Convention

SUIT SYNTAX

LEARN SUIT: CSS naming conventions

.ComponentNameMust be written in pascal case. Examples: .MyBtn or .LoginForm

COMPONENTS

Page 22: Learn SUIT: CSS Naming Convention

SUIT SYNTAX

LEARN SUIT: CSS naming conventions

.ComponentNameMust be written in pascal case. Examples: .MyBtn or .LoginForm

.ComponentName-descendentNameMust be written in camel case. Examples: .MyBtn-priceBox or .MyBtn-textBox

$150 SUBSCRIBE NOW

COMPONENTS

DESCENDENTS

Page 23: Learn SUIT: CSS Naming Convention

SUIT SYNTAX

$150 SUBSCRIBE NOW

LEARN SUIT: CSS naming conventions

.ComponentNameMust be written in pascal case. Examples: .MyBtn or .LoginForm

.ComponentName-descendentNameMust be written in camel case. Examples: .MyBtn-priceBox or .MyBtn-textBox

$150 SUBSCRIBE NOW

COMPONENTS

DESCENDENTS

MODIFIERS

.ComponentName--modifierNameMust be written in camel case. Examples: .MyBtn--important

Page 24: Learn SUIT: CSS Naming Convention

SUIT SYNTAX: HOW TO REMEMBER ITS RULES

LEARN SUIT: CSS naming conventions

I know it seems ridiculous, but mnemonics work with this things ;)

PascaL firstCamel secondCamel

Page 25: Learn SUIT: CSS Naming Convention

SUIT SYNTAX: HOW TO REMEMBER ITS RULES

LEARN SUIT: CSS naming conventions

I know it seems ridiculous, but mnemonics work with this things ;)

PascaL

ComponentNameMust be written in pascal case.

Page 26: Learn SUIT: CSS Naming Convention

SUIT SYNTAX: HOW TO REMEMBER ITS RULES

LEARN SUIT: CSS naming conventions

I know it seems ridiculous, but mnemonics work with this things ;)

PascaL firstCamel

ComponentName -descendentNameMust be written in camel case.Must be written in pascal case.

Page 27: Learn SUIT: CSS Naming Convention

SUIT SYNTAX: HOW TO REMEMBER ITS RULES

LEARN SUIT: CSS naming conventions

I know it seems ridiculous, but mnemonics work with this things ;)

PascaL firstCamel secondCamel

ComponentName -descendentName --modifierNameMust be written in camel case. Must be written in camel case.Must be written in pascal case.

Page 28: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT: MyBtnstyles.css

/* Component */.MyBtn { styles here }

CSS

index.html

<a href="#" class="MyBtn"></a>

HTML

Page 29: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT: MyBtn

$150 SUBSCRIBE NOW

DESCENDENT: price DESCENDENT: text

styles.css

/* Component */.MyBtn { styles here }

/* Descendents: depend upon the component */.MyBtn-price { styles here }.MyBtn-text { styles here }

CSS

index.html

<a href="#" class="MyBtn"> <span class="MyBtn-price">$150</span> <span class="MyBtn-text">Subscribe now</span> </a>

HTML

Page 30: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT: MyBtn

$150 SUBSCRIBE NOW

styles.css

/* Component */.MyBtn { styles here }

/* Descendents: depend upon the component */.MyBtn-price { styles here } .MyBtn-text { styles here }

/* Modifier: change style of the component */.MyBtn--important { styles here }

CSS

index.html

<a href="#" class="MyBtn MyBtn--important"> <span class="MyBtn-price">$150</span> <span class="MyBtn-text">Subscribe now</span> </a>

HTML

Page 31: Learn SUIT: CSS Naming Convention

LEARN SUIT: CSS naming conventions

COMPONENT: MyBtn

$150 SUBSCRIBE NOW

styles.css

/* Component */.MyBtn { styles here }

/* Descendents: depend upon the component */.MyBtn-price { styles here }.MyBtn-text { styles here }

/* Modifier: change style of the component */.MyBtn-text--important { styles here }

CSS

index.html

<a href="subscribe.html" class="MyBtn"> <span class="MyBtn-price">$150</span> <span class="MyBtn-text MyBtn-text--important">Subscribe now</span> </a>

HTML

Page 32: Learn SUIT: CSS Naming Convention

USEFUL REFERENCES

LEARN SUIT: CSS naming conventions

SUIT CSS: NAMING CONVENTIONS

SUIT CSS relies on structured class names and meaningful hyphens. github.com/suitcss/suit/blob/master/doc/naming-conventions.md

SUIT CSS: STYLE TOOLS FOR UI COMPONENTS

SUIT CSS is a reliable and testable styling methodology for component-based UI development. suitcss.github.io

Page 33: Learn SUIT: CSS Naming Convention

Are you also interested in learning

BOOTSTRAP 4POSTCSS?+

http://inarocket.teachable.com/courses/css-postcssPlease visit:

Page 34: Learn SUIT: CSS Naming Convention

Learn front-end development at rocket speed

inarocket.com

by miguelsanchez.com

Page 35: Learn SUIT: CSS Naming Convention

inarocket.com

Learn at rocket speed

SUITCSS NAMING CONVENTION