Skip to content

Commit

Permalink
Turn the example into markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
vocksel committed Jan 4, 2024
1 parent c0bb6ca commit c7c2e15
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 54 deletions.
54 changes: 0 additions & 54 deletions src/Renderers/example.lua

This file was deleted.

72 changes: 72 additions & 0 deletions src/Renderers/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Plain GuiObjects

```lua
exports.Primary = {
args = {
isEnabled = true,
},
renderer = RobloxRenderer,
render = function(args)
local label = Instance.new("TextLabel")
label.Text = if args.isEnabled then "Enabled" else "Disabled"

return label
end
```
}

Fusion

```lua
local function Button(props)
local isHovering = Value(false)

return New "TextButton" {
BackgroundColor3 = Computed(function()
return if isHovering:get() then HOVER_COLOUR else REST_COLOUR
end),

[OnEvent "MouseEnter"] = function()
isHovering:set(true)
end,

[OnEvent "MouseLeave"] = function()
isHovering:set(false)
end,

-- ... some properties ...
}
end

local exports = {}
exports.Primary = {
args = {
isEnabled = true,
},
renderer = createFusionRenderer(Fusion),
render = function(args)
return New "TextLabel" {
Text = Computed(function()
return if args.isEnabled:get() then "Enabled" else "Disabled"
end)
}
end
}
```


React

```lua
exports.Primary = {
args = {
isEnabled = true,
}
renderer = createReactRenderer(React, ReactRoblox),
render = function(args)
return React.createElement("TextLabel", {
Text = if args.isEnabled then "Enabled" else "Disabled"
})
end
}
```

0 comments on commit c7c2e15

Please sign in to comment.