customize.html 3.3 KB

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