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

🎉 Switch to SASS #18

Merged
merged 16 commits into from Mar 8, 2017
Merged

🎉 Switch to SASS #18

merged 16 commits into from Mar 8, 2017

Conversation

enzy
Copy link
Contributor

@enzy enzy commented Mar 7, 2017

  • whitespace syntax
  • using normalize-scss
  • using Bourbon mixins
  • $manifest variable is gone
  • mango-cli v0.30+

Closes #17

Copy link
Contributor

@JirkaVebr JirkaVebr left a comment

Choose a reason for hiding this comment

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

Pěkně! 🙂

Jinak nepřidáme ještě ty position mixiny? Ten size už dodává Bourbon a same byl spíš takovej experiment, ale ty position mixiny jsou podle mě lepší, než Bourboní position.

clip: rect(1px, 1px, 1px, 1px)
overflow: hidden
size: 1px 1px
.fleft
Copy link
Collaborator

Choose a reason for hiding this comment

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

K čemu tu vlastně stále máme .fleft, .fright a .clear? Nepřišlo mi to užitečné dříve a nepřijde mi to ani teď. Akorát si tím rozbíjíme koncept modulárního css.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a .accessible ti nevadí? Je to stejný princip utilitek, které se nevyplatí psát přímo do komponenty

Copy link
Contributor

Choose a reason for hiding this comment

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

Já souhlasím s tím, že fleft, fright a clear nejsou úplně sémantické. Zrušil bych je a z .accessible udělal extend-only selector (nebo klidně mixin) a pak ho explicitně volal z komponent.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Kdyby .accessible bylo v parts nebo v abstract pro jednoduchý @extend, tak jsem s ním úplně spokojený. Je to k něčemu dobré a skoro to respektuje modulární css (vadí mi jen umístění do global).

Vzhledem k tomu, že v našich HTML má téměř každý element třídu, .fleft, .fright a .clear neusnadňuje nic, protože místo toho stačí napsat jen float left, float right a clear both, což je sice o pár znaků delší, ale je to známým jazykem, na očekávaném místě a podporuje to modifikace třeba v breakpointech. .fleft mi přijde podobně hloupé jako třeba dflex pro display flex, který navíc používáme mnohem častěji.

Proč .fleft a ostatní chceme? Ještě jsem na jejich použití v žádném codereview nenarazil.

@@ -0,0 +1,3 @@
.appName
padding-left: 0.3em
border-left: 0.3em solid $c-main
Copy link
Collaborator

Choose a reason for hiding this comment

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

To, že jsi zahodil manifest, mě dost mrzí. :( Co já vím, tak přítomnost manifestu například zvyšuje hodnocení v Googlu. Čím více ten manifest integrujeme do zbytku examplu, tím je jistější, že bude v každém projektu z něj vycházejícím dostatečně udržovaný.


// Shapes default dimensions
&-plus
+size(20px)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Proč řádek 84cd298#diff-9ca1fe03ff873ff03f519cea30829fb7R75 není zapsaný stejně jako tady?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

není, mohl by

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok

$portrait: '(orientation: portrait)'

// Animations
@keyframes spin
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nechceme pro animations vlastní složku na na úrovni comps a parts? Řekl bych, že na Darujme se nám to osvědčilo.
Cc. @JirkaVebr

@@ -1,58 +0,0 @@
// App manifest
$manifest = json('../data/manifest.json', { hash: true })
Copy link
Collaborator

Choose a reason for hiding this comment

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

Co se ti na tomhle nelíbí?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SASS to neumí. Plugin sice existuje, ale použití proměnných je pak úplně jiné.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Tušil jsem, že jde jen o zjednodušení. Návrat $manifest si tedy beru jako issue na sebe.

@@ -47,6 +47,11 @@ $break1200M: '(max-width: 1199px)'
$landscape: '(orientation: landscape)'
$portrait: '(orientation: portrait)'

// Mixins
=break($min)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

+position(relative, $properties)

// +sticky
=sticky($properties: null null null null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️
Sticky nib/stylus neumí.

@@ -48,10 +48,16 @@ $landscape: '(orientation: landscape)'
$portrait: '(orientation: portrait)'

// Mixins

// +break(768) => @media (min-width: 768px)
=break($min)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nechceme zahodit ty konstantní deklarace? $break320: '(min-width: 320px)', ...

// +media($break320M) => @media (max-width: 319px)
=media($var)
@media #{$var}
@content
Copy link
Contributor

Choose a reason for hiding this comment

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

Úplně se mi nelíbí, že jsou takhle dva separátní mixiny, a že navíc chybí něco jako breakM, tak jsem napsal univerzální řešení. Je to pohodlnější, flexibilnější a líp se s tím pracuje za použití proměnných. Klidně o tom diskutujme a společně to vylepšeme (zejména s tou magií s M mnozí klidně můžou mít problém), ale podle mě není důvod mít takhle dva separátní spíše kostrbaté mixiny.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Wow. :)

Hele, proč je tam $literal * 0? Co to dělá?

Copy link
Contributor

Choose a reason for hiding this comment

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

Je to takovej trik na zbavení se jednotky, pokud tam nějaká je. $literal * 0 udělá z 123px 0px. Pak to + 1 udělá z 0px 1px a $literal / 1px, tedy 123px / 1px, je 123.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Dík. :)

Co to 123px / 1px? Zbyde jen 123, protože jednotky se vykrátí? :D

Copy link
Contributor

Choose a reason for hiding this comment

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

Ano, přesně tak ‒ funguje to úplně stejně jako ve fyzice. Podobně jako 2px * 3px je v sassu 6px*px. 😃

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oukej. :D :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tohle byla co nejjednodušší rychlovka... Codepen vypadá fajn, co k tomu přidat nějakou dokumentaci, ať to umí pak každej používat? :)


// +absolute(0 10px 0 10px), order by specs: top right bottom left
=absolute($properties: null null null null)
+position(absolute, $properties)
Copy link
Contributor

Choose a reason for hiding this comment

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

Proč Ti prosím přijde tohle lepší než to mnou navržené řešení? Osobně s tím moc nesouhlasím ‒ nemyslím si, že je +absolute(null 10px null 0) jakkoliv čitelnější či pohodlnější než +absolute(right 10px, left). Navíc jsme na to byli z nibu zvyklí.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

více psaní, vyhledatelnost chování v dokumentaci, shorthand zápis dle zvyků v CSS

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, fair enough. 🙂 Zmátl mě ten příklad +absolute(0 10px 0 10px) ‒ myslel jsem, že to znamená, že člověk vždycky musí takhle psát všechny čtyři hodnoty. Ono ale funguje i +absolute(0 10px), a to pak dává smysl. Mea culpa.


// +sticky
=sticky($properties: null null null null)
+position(sticky, $properties)
Copy link
Contributor

Choose a reason for hiding this comment

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

Jinak podle mě by bylo lepší mixiny dát do separé souboru.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Už mi také přišlo, ale ještě jsem neřešil.

@JirkaVebr JirkaVebr requested a review from hexcross March 7, 2017 14:59
@JirkaVebr
Copy link
Contributor

JirkaVebr commented Mar 7, 2017

@enzy Já se domnívám, že ne. Mít to ve variables je bordel a dávat je do parts je jen spoléhání se na to, že jméno animace je abecedně dřív než jméno komponent, které by tu animaci rády využily. Těch animací bude sice pár, ale i tak je tohle podle mě nejlepší řešení.
Edit: reaguju na ty animace, of course… 🙂

@FilipChalupa
Copy link
Collaborator

@JirkaVebr Animace se do parts nehodí, ale jinak jim nevadí, jestli keyframes mají zadefinované před nebo až po vlastním použití, takže na abecedě nezáleží.

@JirkaVebr
Copy link
Contributor

@onset Máš pravdu, to jsem si spletl s abstract. I tak bych je ale do variables.sass ani přímo do styles/ nedával.

Copy link
Contributor Author

@enzy enzy left a comment

Choose a reason for hiding this comment

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

Reasoning za vlastním souborem: Přehled všech možností ve file tree, předcházení konfliktů, přehlednost v souboru.
Animace jsou ale max. na pár řádků a nepoužívá se jich na projektech tolik, aby v nich začal být nepořádek a potřebovali jsme toto řešení.

Mixiny si naopak zaslouží vlastní dokumentaci i příklady, jak to Jirka pěkně navrhl, takže tam je to validní.

@FilipChalupa
Copy link
Collaborator

@enzy Zmínil jsi jen samé výhody, proč mít něco ve vlastním souboru. Má to nějaké nevýhody?

@enzy
Copy link
Contributor Author

enzy commented Mar 7, 2017

Nechceme přejít na reviewable? Tohle začíná být docela dost chaos. A to se nepřidal Vilík a David.

Držme citace při odpovědích a bude to fajn. Rewiable tomuto moc nepomůže.

Zmínil jsi jen samé výhody, proč mít něco ve vlastním souboru. Má to nějaké nevýhody?

@onset Založení souboru a vůbec manipulace se soubory (přejmenování) je výrazně pomalejší, nežli s textem v jednom souboru. Dále narůstá velikosti stromu souborů, která při určitě hranici začíná být kontraproduktivní.

@FilipChalupa
Copy link
Collaborator

@enzy IMHO, když máš těch souborů pár, tak tě problém s manipulací neobtěžuje, protože prakticky vůbec nemanipuluješ. Jak je těch souborů víc, tak je lepší pro ně, pro animace, mít jednotnou přehlednou strukturu, takže se prostě vyplatí udržovat strukturu i v případě, že animací je málo, protože je to příprava na stav, kdy se jejich množství zvedne.

@JirkaVebr
Copy link
Contributor

@enzy Já uvažoval následovně:

  • Necháme-li animace ve variables, bude v tom bordel, protože tam prostě nepatří, neboť to jednoduše žádné proměnné nejsou.
  • Dáme-li každou animaci do parts/, bude v tom bordel, protože člověk na první pohled nepozná, co je komponenta, a co je animace. To je zkrátka nepřehledné a to, že těch animací není tolik, na tom imho nic nemění.
  • Bude-li si každá komponenta definovat vlastní keyframes, je to zbytečně ne-DRY.

Jediná dvě rozumná řešení, která mě napadají, je mít ve styles/ soubor animations.sass nebo to dát do té samostatné složky, jak jsem to teď commitnul. Klidně ty animations.sass vytvořím, to je asi jedno. Ostatně i na Darujme, projektu jako kráva, těch animací máme jen šest. Nevýhodou je, že to bude trochu haprovat, pokud těch animací jednou skutečně bude hodně, nebo pokud se třeba nějaká hodně rozroste. Pak ale asi není problém to operativně přepsat na ten způsob se složkou, ikdyž souhlasím s Fílou, že je potom lepší to tak mít rovnou ‒ ten způsob se složkou je zkrátka univerzálnější. Jen bych prosím rozhodně nešel ani jednou z cest popsaných v těch bodech výše.

@enzy
Copy link
Contributor Author

enzy commented Mar 7, 2017

Ještě prohloubení myšlenky... Až začneme používat CSS variables, kam je budeme umisťovat? Můžeme také namítat, že to nejsou vlastně SASS variables, takže by měly patřit jinam, ať nemícháme jablka s hruškami...
A file tree nám bude bobtnat a bobtnat. Takže je to vždy balanc mezi striktním svazujícím oddělováním a uvolňující benevolencí.

Pokud to opravdu chceme oddělit, prosím do styles/_animations.sass

$em-base: $base-font-size

// Colors
$c-main: green
Copy link
Contributor

Choose a reason for hiding this comment

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

Když už se tu dějí věci, tak mi trochu tady některé proměnné překáží. Třeba tyhle barvy. Snad nikdy jsem je nezměnil, protože jsem něvěděl na co a potom to místy bylo na nic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Umm, tomuhle vůbec nerozumím. Úplně každý web má přece nějakou barevnou paletu, přičemž ty nejdůležitější barvy se objevují hodně často v mnoha komponentách. Je dobré pro ně mít sémantické názvy, ne? Třeba u Rekol by $c-main byla ta růžová, protože tu barvu člověkv kódu potřebuje hodně. Souhlasím, že je mnohdy nesnadné ty barvy sémanticky pojmenovat, ale je to rozhodně lepší než hlavní odstíny hardcodovat (asi u půlky projektů, na kterých jsem kdy dělal, se v průběhu vývoje změnil design…) nebo je pojmenovávat stylem $green.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Za mě $c-main dobré, ale jak správně použít ty další vůbec netuším ($c-comp, $c-alt, $text-color-light - které navíc z nějakého důvodu nezačíná na $c-).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ten prefix je fail, s tím souhlasim, to už jsem taky chtěl změnit ‒ udělám to za chvilku.
Jinak alt a comp může být legrace, ale jaká je lepší alternativa? $c-gray?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Já nevím, co je alt a comp, ale $c-gray rozhodně není dobré pojmenování nezávisle na tom, co to má být.

Copy link

@hexcross hexcross Mar 8, 2017

Choose a reason for hiding this comment

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

Mě proměnné na barvy taky nevadí, než začnu reálně kodovat tak si přesně do variables.styl definuju fonty, barvy, radius atd...různý barvy řeším jako c-primary nebo c-secondary a jejich varianty prefixem -light nebo -dark a na to zpravidla pouzivam mixin např. lighten($c-primary, 10%). Víc základních barev než 2 se většinou nepoužívají, a pokud pro nějaký komponenty jo tak pro dalsi barvy pouzivam c-red apod. Prijde mi to v pohode, protoze ty barvy se na webu opakujou a nikdy jsem se nesetkal se situci ze bych musel z c-red udelat treba modrou. Kdyz uz se neco meni tak je to c-primary resp. c-main. Jinak prefix -alt taky moc nepouzivam, pokud jo tak je to na kontrastni barvu.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • comp - complementary color (k main barvě)
  • alt - alternative color (ala secondary)
  • text-color- jsou bootstrap proměnné

Copy link
Collaborator

Choose a reason for hiding this comment

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

Trochu mi i comp zní jako secondary. Jaké je prosím pro comp nějaké konkrétní použití?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Aha, už chápu. Complement jako doplněk, jako opak.

$fw-normal: 400
$fw-medium: 500
$fw-semibold: 600
$fw-bold: 700
Copy link
Contributor

Choose a reason for hiding this comment

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

A k čemu je vlastně tohle? Použil to někdy někdo? Mě přijde i čitelnější když je v kódu font-weight: 700, než s nějakou variable...

Copy link
Contributor

Choose a reason for hiding this comment

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

Je to v zásadě totéž, jako jsem vysvětloval u media queries ‒ takhle Ti to zařve při překlepu, líp Ti našeptává IDE, nemusíš si přesně pamatovat čísla a změny jsou snáz proveditelné. Ani jednu z těchto výhod psaní konstant nemá.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Čísla si nemusíš pamatovat ani když použiješ bold, normal, ... a IDE ti taky našeptá.

@JirkaVebr Mimochodem na Darujme v intervalu jednoho měsíce používáš $fw-bold i bold.

Copy link
Contributor

Choose a reason for hiding this comment

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

A co až budeš chtít použít light, semi-bold nebo extra-bold? To budeme mixovat bold a 300? Pak si ta čísla člověk stejně nakonec pamatovat musí, nemá-li proměnné.

na Darujme v intervalu jednoho měsíce používáš

@onset Tak jsi mi to měl omlátit o hlavu při review. To, že nejsem neomylný, tady přece vůbec relevantní není…

Copy link
Collaborator

Choose a reason for hiding this comment

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

Máš point, ale je fakt, že ty proměnné snad vůbec nikdo nepoužívá dobře. Zrovna na Darujme v tom děláš bordel ty, Honza, ale i já, takže ti to těžko můžu omlátit o hlavu, když to sám neovládám. Že v tom děláš chyby byl teď nejdříve jen můj odhad, protože mi to bylo úplně jasné. :D

// Font properties
$font-family-sans-serif: 'Helvetica Neue', Helvetica, Arial, sans-serif
$font-family-serif: Georgia, Cambria, 'Times New Roman', Times, serif
$font-family-monospace: Monaco, Menlo, Consolas, 'Courier New', monospace
Copy link
Contributor

Choose a reason for hiding this comment

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

A k čemu je tohle? To nechápu využití....

Copy link
Contributor

Choose a reason for hiding this comment

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

Není to hardcoded do deklarací, ale je to vyčleněo sem, díky čemuž člověk může relevantní věci snadno měnit přímo z variables (kam jinam bys jako první šel, kdyby Ti grafik řekl, že se změnilo písmo?). Používá se to (nepřímo) mimo jiné v global.sass.

$text-back: #FFF
$c-text: $c-comp
$c-text-light: #676767
$c-text-back: #FFF
Copy link
Collaborator

Choose a reason for hiding this comment

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

Já bych ideálně z $c-text-back vyhodil to -text. Nedává mi tam příliš smysl nebo používám tuhle proměnnou špatně, ale vnímám ji obecněji než jen jako pozadí pro text.

@import 'variables'

// ## Animations
@import '_animations'
Copy link

Choose a reason for hiding this comment

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

Proc má tenhle jedinej soubor podtržítko?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevim, výše to navrhl @enzy a já se nad tim moc nezamyslel. 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

V SASS se tak označují partials a tady nám to pěkně odděluje hlavní soubory od vedlejších. Ještě bychom mohli přejmenovat další, ať je to patrné.

Nicméně komponenty a další soubory ve složkách už tak dělat není potřeba.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Další jsou které? variables a global?

@enzy enzy merged commit faa0876 into master Mar 8, 2017
@enzy enzy deleted the sass branch December 14, 2017 10:15
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.

None yet

5 participants