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
🎉 Switch to SASS #18
Conversation
- $manifest is missing as json read is not supported yet
There was a problem hiding this 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
.
src/styles/global.sass
Outdated
clip: rect(1px, 1px, 1px, 1px) | ||
overflow: hidden | ||
size: 1px 1px | ||
.fleft |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
není, mohl by
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
src/styles/variables.sass
Outdated
$portrait: '(orientation: portrait)' | ||
|
||
// Animations | ||
@keyframes spin |
There was a problem hiding this comment.
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 }) |
There was a problem hiding this comment.
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í?
There was a problem hiding this comment.
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é.
There was a problem hiding this comment.
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.
src/styles/variables.sass
Outdated
@@ -47,6 +47,11 @@ $break1200M: '(max-width: 1199px)' | |||
$landscape: '(orientation: landscape)' | |||
$portrait: '(orientation: portrait)' | |||
|
|||
// Mixins | |||
=break($min) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/styles/variables.sass
Outdated
+position(relative, $properties) | ||
|
||
// +sticky | ||
=sticky($properties: null null null null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Sticky nib/stylus neumí.
src/styles/variables.sass
Outdated
@@ -48,10 +48,16 @@ $landscape: '(orientation: landscape)' | |||
$portrait: '(orientation: portrait)' | |||
|
|||
// Mixins | |||
|
|||
// +break(768) => @media (min-width: 768px) | |||
=break($min) |
There was a problem hiding this comment.
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)'
, ...
src/styles/variables.sass
Outdated
// +media($break320M) => @media (max-width: 319px) | ||
=media($var) | ||
@media #{$var} | ||
@content |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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á?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
. 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oukej. :D :D
There was a problem hiding this comment.
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? :)
src/styles/variables.sass
Outdated
|
||
// +absolute(0 10px 0 10px), order by specs: top right bottom left | ||
=absolute($properties: null null null null) | ||
+position(absolute, $properties) |
There was a problem hiding this comment.
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í.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
src/styles/variables.sass
Outdated
|
||
// +sticky | ||
=sticky($properties: null null null null) | ||
+position(sticky, $properties) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@enzy Já se domnívám, že ne. Mít to ve |
@JirkaVebr Animace se do |
@onset Máš pravdu, to jsem si spletl s |
There was a problem hiding this 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í.
@enzy Zmínil jsi jen samé výhody, proč mít něco ve vlastním souboru. Má to nějaké nevýhody? |
Držme citace při odpovědích a bude to fajn. Rewiable tomuto moc nepomůže.
@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í. |
@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. |
@enzy Já uvažoval následovně:
Jediná dvě rozumná řešení, která mě napadají, je mít ve |
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... Pokud to opravdu chceme oddělit, prosím do |
src/styles/variables.sass
Outdated
$em-base: $base-font-size | ||
|
||
// Colors | ||
$c-main: green |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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-
).
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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é
There was a problem hiding this comment.
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í?
There was a problem hiding this comment.
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.
src/styles/variables.sass
Outdated
$fw-normal: 400 | ||
$fw-medium: 500 | ||
$fw-semibold: 600 | ||
$fw-bold: 700 |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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á.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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í…
There was a problem hiding this comment.
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
src/styles/variables.sass
Outdated
// 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 |
There was a problem hiding this comment.
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í....
There was a problem hiding this comment.
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
.
src/styles/variables.sass
Outdated
$text-back: #FFF | ||
$c-text: $c-comp | ||
$c-text-light: #676767 | ||
$c-text-back: #FFF |
There was a problem hiding this comment.
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.
src/styles/index.sass
Outdated
@import 'variables' | ||
|
||
// ## Animations | ||
@import '_animations' |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. 😃
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
- better import position
Closes #17