-
Notifications
You must be signed in to change notification settings - Fork 28
Making Your Own Blocks
Making your own blocks is designed to be straightforward but flexible. I'm hoping to merge most community blocks, so if you do something cool, make a pull request!
Before developing, we should fork the repository so we can make commits and then eventually do a pull request later if we want to.
Just hit the fork button at the top right, and then clone the forked repo.
$ git clone https://github.com/<user>/wired-notify.git
$ cd ./wired_notify
And let's try a build to make sure everything's ok. If this fails, either your rust install is outdated or configured, you're missing dependencies, or I've screwed something up.
$ cargo build
First of all, let's create the file for our block. For the purposes of this tutorial, I'm going to make a simplified NotificationBlock
.
$ ls
src Cargo.toml
TODO: real ls
# Blocks go in /src/rendering/blocks/
$ touch ./src/rendering/blocks/notification_block.rs
Each block should have a Properties
struct which defines both config parameters and internal state. This struct must implement Debug
, Deserialize
, and Clone
.
// /src/rendering/blocks/notification_block.rs
use serde::Deserialize;
#[derive(Debug, Deserialize, Clone)]
pub struct NotificationBlockParameters {
pub border_width: f64,
pub background_color: Color,
pub border_color: Color,
}