customize.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. ---
  2. title: Customize Bulma with Sass
  3. layout: documentation
  4. doc-tab: overview
  5. doc-subtab: customize
  6. breadcrumb:
  7. - home
  8. - documentation
  9. - overview
  10. - overview-customize
  11. ---
  12. {% capture scss_code %}
  13. // 1. Import the initial variables
  14. @import "../sass/utilities/initial-variables";
  15. @import "../sass/utilities/functions";
  16. // 2. Set your own initial variables
  17. // Update blue
  18. $blue: #72d0eb;
  19. // Add pink and its invert
  20. $pink: #ffb3b3;
  21. $pink-invert: #fff;
  22. // Add a serif family
  23. $family-serif: "Merriweather", "Georgia", serif;
  24. // 3. Set the derived variables
  25. // Use the new pink as the primary color
  26. $primary: $pink;
  27. $primary-invert: $pink-invert;
  28. // Use the existing orange as the danger color
  29. $danger: $orange;
  30. // Use the new serif family
  31. $family-primary: $family-serif;
  32. // 4. Setup your Custom Colors
  33. $linkedin: #0077b5;
  34. $linkedin-invert: findColorInvert($linkedin);
  35. $twitter: #55acee;
  36. $twitter-invert: findColorInvert($twitter);
  37. $github: #333;
  38. $github-invert: findColorInvert($github);
  39. // 5. Add new color variables to the color map.
  40. @import "../sass/utilities/derived-variables";
  41. $addColors: (
  42. "twitter":($twitter, $twitter-invert),
  43. "linkedin": ($linkedin, $linkedin-invert),
  44. "github": ($github, $github-invert)
  45. );
  46. $colors: map-merge($colors, $addColors);
  47. // 6. Import the rest of Bulma
  48. @import "../bulma";
  49. {% endcapture %}
  50. <div class="content">
  51. <p>If you're familiar with <a href="http://sass-lang.com/">Sass</a> and want to <strong>customize</strong> Bulma with your own colors and variables, just install Bulma via <strong>npm</strong>:</p>
  52. </div>
  53. <article class="media is-large">
  54. <div class="media-left">
  55. <p class="title is-5">1</p>
  56. </div>
  57. <div class="media-content">
  58. <p class="title is-5">
  59. <strong>Download</strong> the source files:
  60. </p>
  61. {% highlight bash %}npm install bulma{% endhighlight %}
  62. <div class="content">or clone the repository: <a href="https://github.com/jgthms/bulma">https://github.com/jgthms/bulma</a></div>
  63. </div>
  64. </article>
  65. <article class="media is-large">
  66. <div class="media-left">
  67. <p class="title is-5">2</p>
  68. </div>
  69. <div class="media-content">
  70. <p class="title is-5">
  71. <strong>Set</strong> your variables
  72. </p>
  73. <p class="subtitle is-6">
  74. Create a file called <code>mystyles.scss</code> and add your own colors, set new fonts, override Bulma's default styles...
  75. </p>
  76. <div class="highlight-full">
  77. {% highlight sass %}{{ scss_code }}{% endhighlight %}
  78. </div>
  79. </div>
  80. </article>
  81. <article class="media is-large">
  82. <div class="media-left">
  83. <p class="title is-5">3</p>
  84. </div>
  85. <div class="media-content">
  86. <p class="title is-5">
  87. See the <strong>result</strong>: before and after
  88. </p>
  89. <p class="subtitle is-6">
  90. As <code>$blue</code> has been updated, and since <code>$blue-invert</code> is automatically calculated with the <strong>function</strong> <code>$blue-invert: findColorInvert($blue)</code>, the <code>$blue-invert</code> is now black instead of white</p>
  91. </p>
  92. <figure>
  93. <img width="640" height="640" src="{{site.url}}/images/customize-before.png" alt="Customizing Bulma with Sass">
  94. <img width="640" height="640" src="{{site.url}}/images/customize-after.png" alt="Customizing Bulma with Sass">
  95. </figure>
  96. </div>
  97. </article>