Building the Board Layout
Building the Board Layout
Before we dive into code, let's understand what we need to build next. A Kanban board is essentially a collection of columns, each representing a different stage in your workflow.
For our application, we'll create a board layout with three columns: "To Do," "In Progress," and "Done." These columns will be arranged horizontally on desktop screens and will stack vertically on mobile devices for better usability.
Creating this layout requires two key steps:
- Building a dedicated Board component that handles the overall arrangement
- Styling it with Flexbox to achieve responsive behavior
The Board component will serve as a container for our columns, managing their organization and spacing. This component-based approach keeps our code modular and easier to maintain as our application grows.
From Page To Board Component
In our previous lesson, we created the main page structure with +page.svelte. Now, we'll build the Board component - the central element of our Kanban system that will organize and display our task columns.
This step moves us from the outer container to the next layer in our component hierarchy. Remember our application structure from lesson 1:
Let's create a new file called Board.svelte in the src/components directory. This component will be imported into our main page.
Notice we're using simple <div> elements as placeholders for now. In our next lesson, we'll replace these with proper column components. The important part is establishing the structure first.
Flexbox Layout For Columns
Now let's implement the visual layout using Flexbox. We want our columns to display horizontally on desktops and stack vertically on mobile devices:
Here's what we're doing with this CSS:
display: flexon the board container creates our horizontal layoutgap: 1remadds consistent spacing between columns- The media query makes our layout responsive by switching to vertical on smaller screens
- Each column has styling for padding, rounded corners, and a subtle shadow for visual depth
When rendered, our board will look something like this:
Integration With The Main Page
Now that we have our board component ready, let's connect it to our main page by modifying the +page.svelte file:
This demonstrates a key concept in Svelte component composition:
- We import the Board component using ES6 import syntax
- We use the component in our template with
<Board /> - The component's contents will appear exactly where we place the tag
This pattern of composing small, focused components into larger ones is fundamental to modern web development. Our main page handles the overall container, while the Board component handles column arrangement.
Review & Practice Prep
In this lesson, we've built the structural foundation for our Kanban board. You've learned how to:
- Create a dedicated board component
- Implement responsive Flexbox layouts
- Connect components together through imports
In the practice exercises, you'll:
- Adjust the flexbox gap and column widths
- Test different media query breakpoints
- Experiment with additional visual styles
In our next lesson, we'll replace these placeholder divs with proper column components that can hold tasks. We're following our architectural plan by building from the outside in - first the page, then the board, and next the columns.
