{"id":1,"date":"2016-08-12T18:30:07","date_gmt":"2016-08-12T18:30:07","guid":{"rendered":"http:\/\/iamakulov.com\/notes2\/?p=1"},"modified":"2017-05-05T22:12:20","modified_gmt":"2017-05-05T22:12:20","slug":"composes-in-css-modules","status":"publish","type":"post","link":"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/","title":{"rendered":"\u201ccomposes:\u201d in CSS Modules"},"content":{"rendered":"<p>On our project in EPAM, we\u2019re currently busy with integrating React stack into our infrastructure. Had an interesting discussion about CSS Modules today: should we use <a href=\"https:\/\/github.com\/css-modules\/css-modules#composition\">composes<\/a> in our code?<\/p>\n<p>Several interesting points:<\/p>\n<ul>\n<li><em>composes<\/em>\u00a0is an official way to compose classes, however, it breaks compatibility with the real CSS. If we use <em>composes<\/em>, it\u2019d be hard to migrate from CSS Modules to something else in the future.<\/li>\n<li><a href=\"http:\/\/www.html5rocks.com\/en\/tutorials\/webcomponents\/shadowdom\/\">Shadow DOM<\/a> is cool and should be released in the major browsers <a href=\"http:\/\/caniuse.com\/#feat=shadowdom\">pretty soon<\/a>. A colleague believes once Shadow DOM becomes widely available, CSS Modules will get much less popular pretty soon. A major advantage of Modules is the incapsulation of styles, and Shadow DOM does this natively. Therefore, using CSS Modules in a long-term project is probably a bad idea.<\/li>\n<li>There\u2019s no official documentation on why <em>composes<\/em> was chosen over the traditional way of combining several classes, like <em>&lt;button class=&#8221;button button-green&#8221;&gt;<\/em>. Probably I haven\u2019t found it. I believe <em>composes<\/em> exists because it is cleaner than combining several classes:\n<pre><code >&lt;!-- With composes --&gt;\r\n&lt;button className={styles.buttonGreen}&gt;\r\n\r\n&lt;!-- Without composes --&gt;\r\n&lt;button className={styles.button + ' ' + styles.buttonGreen}&gt;\r\n<\/code><\/pre>\n<p>but the real decision is still unclear.<\/li>\n<\/ul>\n<p>(Originally published on <a href=\"http:\/\/iamakulov.tumblr.com\/post\/148357917855\/composes-in-css-modules\">Tumblr<\/a>.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On our project in EPAM, we\u2019re currently busy with integrating React stack into our infrastructure. Had an interesting discussion about CSS Modules today: should we use composes in our code? Several interesting points: composes\u00a0is an official way to compose classes, however, it breaks compatibility with the real CSS. If we use composes, it\u2019d be hard &hellip; <a href=\"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;\u201ccomposes:\u201d in CSS Modules&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[8],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-css-modules"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u201ccomposes:\u201d in CSS Modules - Ivan Akulov\u2019s blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u201ccomposes:\u201d in CSS Modules - Ivan Akulov\u2019s blog\" \/>\n<meta property=\"og:description\" content=\"On our project in EPAM, we\u2019re currently busy with integrating React stack into our infrastructure. Had an interesting discussion about CSS Modules today: should we use composes in our code? Several interesting points: composes\u00a0is an official way to compose classes, however, it breaks compatibility with the real CSS. If we use composes, it\u2019d be hard &hellip; Continue reading &quot;\u201ccomposes:\u201d in CSS Modules&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/\" \/>\n<meta property=\"og:site_name\" content=\"Ivan Akulov\u2019s blog\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/iamakulov.page\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-12T18:30:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-05-05T22:12:20+00:00\" \/>\n<meta name=\"author\" content=\"Ivan Akulov\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@iamakulov\" \/>\n<meta name=\"twitter:site\" content=\"@iamakulov\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ivan Akulov\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/composes-in-css-modules\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/composes-in-css-modules\\\/\"},\"author\":{\"name\":\"Ivan Akulov\",\"@id\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/#\\\/schema\\\/person\\\/ebf7b61bf573e7be5fe438f50ebd9b81\"},\"headline\":\"\u201ccomposes:\u201d in CSS Modules\",\"datePublished\":\"2016-08-12T18:30:07+00:00\",\"dateModified\":\"2017-05-05T22:12:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/composes-in-css-modules\\\/\"},\"wordCount\":218,\"commentCount\":0,\"keywords\":[\"css modules\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/iamakulov.com\\\/notes\\\/composes-in-css-modules\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/composes-in-css-modules\\\/\",\"url\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/composes-in-css-modules\\\/\",\"name\":\"\u201ccomposes:\u201d in CSS Modules - Ivan Akulov\u2019s blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/#website\"},\"datePublished\":\"2016-08-12T18:30:07+00:00\",\"dateModified\":\"2017-05-05T22:12:20+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/#\\\/schema\\\/person\\\/ebf7b61bf573e7be5fe438f50ebd9b81\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/composes-in-css-modules\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/iamakulov.com\\\/notes\\\/composes-in-css-modules\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/composes-in-css-modules\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u201ccomposes:\u201d in CSS Modules\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/#website\",\"url\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/\",\"name\":\"Ivan Akulov\u2019s blog\",\"description\":\"Ivan Akulov writes about his front-end experience, React, webpack, and performance optimizations.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/iamakulov.com\\\/notes\\\/#\\\/schema\\\/person\\\/ebf7b61bf573e7be5fe438f50ebd9b81\",\"name\":\"Ivan Akulov\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aec4e9e944911b58f2c3d14b7f9e5412a217e5738359c3f52e824b4de2b2263c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aec4e9e944911b58f2c3d14b7f9e5412a217e5738359c3f52e824b4de2b2263c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aec4e9e944911b58f2c3d14b7f9e5412a217e5738359c3f52e824b4de2b2263c?s=96&d=mm&r=g\",\"caption\":\"Ivan Akulov\"},\"description\":\"I'm a software engineer specializing in web performance, JavaScript, and React. I\u2019m also a Google Developer Expert. I work at Framer.\",\"sameAs\":[\"http:\\\/\\\/iamakulov.com\",\"https:\\\/\\\/x.com\\\/iamakulov\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u201ccomposes:\u201d in CSS Modules - Ivan Akulov\u2019s blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/","og_locale":"en_US","og_type":"article","og_title":"\u201ccomposes:\u201d in CSS Modules - Ivan Akulov\u2019s blog","og_description":"On our project in EPAM, we\u2019re currently busy with integrating React stack into our infrastructure. Had an interesting discussion about CSS Modules today: should we use composes in our code? Several interesting points: composes\u00a0is an official way to compose classes, however, it breaks compatibility with the real CSS. If we use composes, it\u2019d be hard &hellip; Continue reading \"\u201ccomposes:\u201d in CSS Modules\"","og_url":"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/","og_site_name":"Ivan Akulov\u2019s blog","article_publisher":"http:\/\/facebook.com\/iamakulov.page","article_published_time":"2016-08-12T18:30:07+00:00","article_modified_time":"2017-05-05T22:12:20+00:00","author":"Ivan Akulov","twitter_card":"summary_large_image","twitter_creator":"@iamakulov","twitter_site":"@iamakulov","twitter_misc":{"Written by":"Ivan Akulov","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/#article","isPartOf":{"@id":"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/"},"author":{"name":"Ivan Akulov","@id":"https:\/\/iamakulov.com\/notes\/#\/schema\/person\/ebf7b61bf573e7be5fe438f50ebd9b81"},"headline":"\u201ccomposes:\u201d in CSS Modules","datePublished":"2016-08-12T18:30:07+00:00","dateModified":"2017-05-05T22:12:20+00:00","mainEntityOfPage":{"@id":"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/"},"wordCount":218,"commentCount":0,"keywords":["css modules"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/","url":"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/","name":"\u201ccomposes:\u201d in CSS Modules - Ivan Akulov\u2019s blog","isPartOf":{"@id":"https:\/\/iamakulov.com\/notes\/#website"},"datePublished":"2016-08-12T18:30:07+00:00","dateModified":"2017-05-05T22:12:20+00:00","author":{"@id":"https:\/\/iamakulov.com\/notes\/#\/schema\/person\/ebf7b61bf573e7be5fe438f50ebd9b81"},"breadcrumb":{"@id":"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/iamakulov.com\/notes\/composes-in-css-modules\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/iamakulov.com\/notes\/"},{"@type":"ListItem","position":2,"name":"\u201ccomposes:\u201d in CSS Modules"}]},{"@type":"WebSite","@id":"https:\/\/iamakulov.com\/notes\/#website","url":"https:\/\/iamakulov.com\/notes\/","name":"Ivan Akulov\u2019s blog","description":"Ivan Akulov writes about his front-end experience, React, webpack, and performance optimizations.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/iamakulov.com\/notes\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/iamakulov.com\/notes\/#\/schema\/person\/ebf7b61bf573e7be5fe438f50ebd9b81","name":"Ivan Akulov","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/aec4e9e944911b58f2c3d14b7f9e5412a217e5738359c3f52e824b4de2b2263c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/aec4e9e944911b58f2c3d14b7f9e5412a217e5738359c3f52e824b4de2b2263c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/aec4e9e944911b58f2c3d14b7f9e5412a217e5738359c3f52e824b4de2b2263c?s=96&d=mm&r=g","caption":"Ivan Akulov"},"description":"I'm a software engineer specializing in web performance, JavaScript, and React. I\u2019m also a Google Developer Expert. I work at Framer.","sameAs":["http:\/\/iamakulov.com","https:\/\/x.com\/iamakulov"]}]}},"jetpack_shortlink":"https:\/\/wp.me\/p8Hto2-1","jetpack-related-posts":[{"id":1065,"url":"https:\/\/iamakulov.com\/notes\/walmart\/","url_meta":{"origin":1,"position":0},"title":"Case study: analyzing the Walmart site performance","author":"Ivan Akulov","date":"April 27, 2018","format":false,"excerpt":"Walmart is one of the top USA e-commerce retailers. In 2016, they were the second after Amazon by sales. In e-commerce, the conversion is directly affected by how fast the site loads. For many e-commerce companies, making the site faster by 1 second increased the conversion 1.05, 1.1, or even\u2026","rel":"","context":"In \"performance\"","block_context":{"text":"performance","link":"https:\/\/iamakulov.com\/notes\/tag\/performance\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2018\/04\/ApplicationFrameHost_2018-03-30_21-12-46.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2018\/04\/ApplicationFrameHost_2018-03-30_21-12-46.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2018\/04\/ApplicationFrameHost_2018-03-30_21-12-46.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2018\/04\/ApplicationFrameHost_2018-03-30_21-12-46.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2018\/04\/ApplicationFrameHost_2018-03-30_21-12-46.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2018\/04\/ApplicationFrameHost_2018-03-30_21-12-46.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1453,"url":"https:\/\/iamakulov.com\/notes\/lessons-from-self-employment\/","url_meta":{"origin":1,"position":1},"title":"Lessons From Six Years of Self-Employment","author":"Ivan Akulov","date":"February 4, 2024","format":false,"excerpt":"From 2017 to 2023, I worked as a self-employed web performance consultant. I was lucky to do some cool stuff (work with Google and another company every American knows, help many hot startups, speak at worldwide conferences). In 2024, I turned that page and became an employee at Framer, to\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-21-at-21.35.38.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-21-at-21.35.38.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-21-at-21.35.38.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-21-at-21.35.38.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-21-at-21.35.38.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/iamakulov.com\/notes\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-21-at-21.35.38.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/iamakulov.com\/notes\/wp-json\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iamakulov.com\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iamakulov.com\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iamakulov.com\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iamakulov.com\/notes\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":10,"href":"https:\/\/iamakulov.com\/notes\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":5,"href":"https:\/\/iamakulov.com\/notes\/wp-json\/wp\/v2\/posts\/1\/revisions\/5"}],"wp:attachment":[{"href":"https:\/\/iamakulov.com\/notes\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iamakulov.com\/notes\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iamakulov.com\/notes\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}