====== Shapes ====== Shapes are handy if you want to add personality to your website. In this chapter, you will learn how to add standard and custom background and image shapes. Background shapes ================= Background shapes are SVG files that you can add as a decorative background in your different sections. Each shape has one or several customizable colors, and some of them are animated. Standard -------- A large selection of default background shapes is available. **Use** .. code-block:: xml
`data-oe-shape-data` is the location of your shape. Flip the shape horizontally or vertically by using the X or Y axis. .. code-block:: xml
Colors mapping ~~~~~~~~~~~~~~ You can also change the default color mapping of your shape. Switch colors mapping ********************* First, put the c* color (here `4`). Then, the replacement color (here `3`). These replacement colors also range from 1 to 5: - `1` = background color of the color preset 1 (o-cc1). - `2` = background color of the color preset 2 (o-cc2). - `3` = background color of the color preset 3 (o-cc3). - `4` = background color of the color preset 4 (o-cc4). - `5` = background color of the color preset 5 (o-cc5). .. code-block:: scss :caption: ``/website_airproof/static/src/scss/boostrap_overridden.scss`` $o-bg-shapes: change-shape-colors-mapping('web_editor', 'Zigs/06', (4: 3, 5: 1)); Add extra colors mapping ************************ Adding extra color mapping allows you to add a color variant to the template of a shape while keeping the original. .. code-block:: scss :caption: ``/website_airproof/static/src/scss/boostrap_overridden.scss`` $o-bg-shapes: add-extra-shape-colors-mapping('web_editor', 'Zigs/06', 'second', (4: 3, 5: 1)); .. code-block:: xml
Custom ------ Sometimes, your design might require creating one or several custom shapes. Firstly, you need to create an SVG file for your shape. .. code-block:: xml :caption: ``/website_airproof/static/shapes/hexagons/01.svg`` Make sure to use colors from the default Odoo palette for your shape. .. code-block:: scss default_palette = { '1': '#3AADAA', '2': '#7C6576', '3': '#F6F6F6', '4': '#FFFFFF', '5': '#383E45', } Declare your shape file. .. code-block:: xml :caption: ``/website_airproof/data/shapes.xml`` 01.svg /web_editor/shape/illustration/hexagons/01.svg .. todo:: Missing description in table ... .. list-table:: :header-rows: 1 :stub-columns: 1 :widths: 20 80 * - Field - Description * - name - Name of the shape * - datas - Path to the shape * - url - ... * - public - Makes the shape available for later editing. Define the styles of your shape. .. code-block:: scss :caption: ``/website_airproof/static/src/scss/primary_variables.scss`` $o-bg-shapes: map-merge($o-bg-shapes, ( 'illustration': map-merge( map-get($o-bg-shapes, 'illustration') or (), ( 'hexagons/01': ('position': center center, 'size': auto 100%, 'colors': (1), 'repeat-x': true, 'repeat-y': true), ), ), ) ); .. list-table:: :header-rows: 1 :stub-columns: 1 :widths: 20 80 * - Key - Description * - File location - `hexagons/01` corresponds to the location of your file in the `shapes` folder. * - position - Defines the position of your shape. * - size - Defines the size of your shape. * - colors - Defines the color c* you want it to have (this will override the color you specified in your SVG). * - repeat-x - Defines if the shape is repeated horizontally. This key is optional and only needs to be defined if set to `true`. * - repeat-y - Defines if the shape is repeated vertically. This key is optional and only needs to be defined if set to `true`. Lastly, add your shape to the list of shapes available on the Website Builder. .. code-block:: xml :caption: ``/website_airproof/views/snippets/options.xml`` Your custom shape can now be used the same way as standard shapes. Image shapes ============ Image shapes are SVG files you can add as a clipping mask on your images. Some shapes have customizable colors, and some are animated. Standard -------- A large selection of default image shapes is available. **Use** .. code-block:: xml ... .. list-table:: :header-rows: 1 :stub-columns: 1 :widths: 20 80 * - Attribute - Description * - data-shape - Location of the shape * - data-shape-colors - Colors applied to the shape .. warning:: Sometimes, your image shape might not be applied after adding your changes. To fix the issue, open the Website Builder and save the page to force the shape to load.