Update examples to widgets instead components

This commit is contained in:
Insality
2025-03-27 00:19:32 +02:00
parent dee77ab313
commit 7640e207a4
47 changed files with 183 additions and 422 deletions

View File

@@ -1,15 +1,9 @@
local component = require("druid.component")
---@class examples.basic_rich_text: druid.component
---@field druid druid.instance
---@class examples.basic_rich_text: druid.widget
---@field rich_text druid.rich_text
local M = component.create("basic_rich_text")
local M = {}
---@param template string
---@param nodes table<hash, node>
function M:init(template, nodes)
self.druid = self:get_druid(template, nodes)
function M:init()
self.druid:new_rich_text("text", "Hello, I'm a <font=text_bold><color=E48155>Rich Text</font></color>!")
end

View File

@@ -1,17 +1,16 @@
local component = require("druid.component")
local helper = require("druid.helper")
---@class examples.rich_text_tags: druid.component
---@field druid druid.instance
---@field rich_text druid.rich_text
local M = component.create("rich_text_tags")
---@class examples.rich_text_tags: druid.widget
---@field rich_text_color druid.rich_text
---@field rich_text_font druid.rich_text
---@field rich_text_size druid.rich_text
---@field rich_text_breaks druid.rich_text
---@field rich_text_image druid.rich_text
---@field position table
local M = {}
---@param template string
---@param nodes table<hash, node>
function M:init(template, nodes)
self.druid = self:get_druid(template, nodes)
function M:init()
self.rich_text_color = self.druid:new_rich_text("rich_text_color") --[[@as druid.rich_text]]
self.rich_text_color:set_text("Hello, I'm a <color=E48155>Rich Text</color> and it's <color=8ED59E>nested <color=A1D7F5>color</color> tag</color>")