2
0

carousel.rst 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. .. _carousel-block:
  2. Carousel Block
  3. ==============
  4. Allows the user to create a carousel with image backgrounds and relevant blocks.
  5. Carousels automatically change slides, but also have arrow controls for the user to advance or return to the previous slide.
  6. Make a Carousel by going to **Snippets > Carousels** and clicking Add Carousel.
  7. Example:
  8. .. figure:: images/carousel_example.jpeg
  9. :alt: default button styles
  10. default button styles
  11. Field Reference
  12. ---------------
  13. Fields and purposes:
  14. * **Carousel** - Choose a Carousel
  15. If you don't have any carousels already made, you can build a carousel by clicking **Choose A Carousel** and
  16. clicking on "Why not **create one now**?" in the popup box. This will take you to **Snippets > Carousels** where
  17. you can create a carousel to add to the page. Here is a carousel editor with three slides; each slide has a caption:
  18. .. figure:: images/carousel_editor.jpeg
  19. :alt: Building a carousel in Snippets
  20. The edit mode for building a carousel snippet
  21. Save your work and now you can select that carousel in a page editor. This one is named Demo. Here is a preview of for one of our slides:
  22. .. figure:: images/carousel_preview.jpeg
  23. :alt: Our carousel published on the page
  24. The carousel published on a page
  25. You'll notice it's hard to see the caption because the bootstrap default text is white. Let's look at customizing our carousel two different ways.
  26. First, you can override the CSS class. If you look at the `bootstrap docs <https://getbootstrap.com/docs/5.2/components/carousel/>`_ or the template.
  27. You'll find the class for caption is ``carousel-caption``. For our example, let's add a background-color and border-radius.
  28. .. code:: CSS
  29. .carousel-caption{
  30. background-color: rgba(60, 60, 60, 0.5);
  31. border-radius: 10px;
  32. }
  33. Add this to your custom.css file (basic installation) or the custom.scss file (sass installation).
  34. Save the file, compile the sass(sass install only), and hard refresh the browser. See :ref:`adding_custom_css` for more details.
  35. .. figure:: images/carousel_preview_bg.jpeg
  36. :alt: Our carousel published on the page
  37. The carousel published on a page
  38. The second option would be to alter the template.
  39. Looking at the `bootstrap docs <https://getbootstrap.com/docs/5.2/components/carousel/>`_ you can find there is a dark variant.
  40. See :ref:`customizing_templates` for a more detailed tutorial on overriding templates.
  41. * To alter our template you need to copy the template from `github <https://github.com/coderedcorp/coderedcms/blob/dev/coderedcms/templates/coderedcms/blocks/carousel_block.html>`_
  42. * Paste the file in the correct directory so it overrides the default template. Our file path: **mysite>website>templates>coderedcms>blocks>carousel_block.html**
  43. * In carousel_block.html on line 4; add carousel-dark to the class attribute. The line should now look like this:
  44. .. code:: html
  45. <div id="carousel-{{self.carousel.id}}" class="carousel carousel-dark slide" data-bs-ride="carousel">
  46. * Save the file and refresh the browser.
  47. .. figure:: images/carousel_preview_dark.jpeg
  48. :alt: Our carousel published on the page
  49. The carousel published on a page
  50. (In this example, I removed the custom css for .carousel-caption from the previous example)