Puzzle Component
General Information
- Puzzle layouts are generated through a svelte
PuzzleLayoutcomponent, which can be imported by including the following line in the file's script tag:
import PuzzleLayout from '$lib/components/PuzzleLayout.svelte'; - A puzzle-like layout is used on several pages, and as such, a component has been made to avoid code repetition and provide consistency between pages. The differences between the configurations of said puzzle layouts are similar, and can thus be easily parameterized.
- The
PuzzleLayoutcomponent provides two panels, the left one being 18 half-blocks wide and the right one 12 half-blocks, creating a separation of two half-blocks between the two panels. Consequently, the component requires a width of 32 half-blocks to be rendered correctly. Note that the content is not the full 12 and 18 half-blocks for the entire height of the layout—cutouts are applied to the bottom-right of the left panel and top-left of the right panel to create the puzzle layout. - The content and background of a panel need to be provided separately, given that the
puzzle-layout makes use of the
Cutoutcomponent, i.e., content that needs to be affected by the cutout needs to be considered background content, such that the remaining content is unaffected by the cutout. - The
PuzzleLayoutcomponent has one optional parameter through which the layout can be configured.includeButtonCutout: Whether the layout should include a cutout in the bottom-right corner that fits a one-block by one-block circle.
- Furthermore, several snippets need to be provided through which components of the puzzle
layout can be rendered. Said snippets can be included within the tags of the
PuzzleLayoutcomponent for convenience.leftBackground(): A snippet that renders the (background) elements that need to be affected by the cutouts in the left side of the puzzle layout.leftContent(): A snippet that renders the content in the left panel of the puzzle layout.rightBackground(): A snippet that renders the (background) elements that need to be affected by the cutouts in the right side of the puzzle layout.rightContent(): A snippet that renders the content in the right panel of the puzzle layout.
Examples
Basic Layout
As noted in the introduction, the default configuration of the puzzle layout requires four snippets, two for each side respectively, where each side is required to the content and background separately. Basic boilerplate code for the default puzzle layout is provided underneath the example.
<PuzzleLayout>
{#snippet leftContent()}
<div class="puzzle-left-content"></div>
{/snippet}
{#snippet rightContent()}
<div class="puzzle-right-content"></div>
{/snippet}
{#snippet leftBackground()}
<div class="background puzzle-left-background"></div>
{/snippet}
{#snippet rightBackground()}
<div class="background puzzle-right-background"></div>
{/snippet}
</PuzzleLayout>
Basic Layout (No Cutout)
Additionally, the puzzle layout can be generated without a cutout in the bottom-right corner.
The latter can be accomplished by setting the includeButtonCutout property to false. Basic boilerplate code for the puzzle layout without a cutout is provided
below.
<PuzzleLayout includeButtonCutout={false}>
{#snippet leftContent()}
<div class="puzzle-left-content"></div>
{/snippet}
{#snippet rightContent()}
<div class="puzzle-right-content"></div>
{/snippet}
{#snippet leftBackground()}
<div class="background puzzle-left-background"></div>
{/snippet}
{#snippet rightBackground()}
<div class="background puzzle-right-background"></div>
{/snippet}
</PuzzleLayout>
Concrete Example (News)
Lastly, a concrete visual demonstration will be given for how the puzzle layout can be used in practice—in this case for the nieuws & blogs page.
Blijf op de hoogte van de laatste ontwikkelingen en gebeurtenissen binnen Spectrum
Wij zijn trots
Op onze samenwerking met Capchemini.Lees hier meer over het traject dat wij aanbieden. Bekijk video