Skip to content

Commit

Permalink
Move sample Modal to SettingsView
Browse files Browse the repository at this point in the history
  • Loading branch information
vocksel committed May 9, 2024
1 parent c0340ff commit ff2be27
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/Plugin/PluginApp.luau
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local Modal = require("@root/Modal/Modal")
local ModalPortal = require("@root/Modal/ModalPortal")
local ModalRoot = require("@root/Modal/ModalRoot")
local NavigationContext = require("@root/Navigation/NavigationContext")
local React = require("@pkg/React")
Expand Down Expand Up @@ -38,26 +36,12 @@ local function App(props: Props)
setSidebarWidth(newSize.X)
end, {})

local isModalShown, setIsModalShown = React.useState(true)
local onCloseModal = React.useCallback(function()
setIsModalShown(false)
end, {})

return React.createElement("Frame", {
BackgroundTransparency = 1,
Size = UDim2.fromScale(1, 1),
}, {
ModalRoot = React.createElement(ModalRoot),

Sample = if isModalShown
then React.createElement(ModalPortal, {}, {
Modal = React.createElement(Modal, {
title = "Example",
onClose = onCloseModal,
}, {}),
})
else nil,

App = React.createElement("Frame", {
BackgroundColor3 = theme.background,
Size = UDim2.fromScale(1, 1),
Expand Down
16 changes: 16 additions & 0 deletions src/UserSettings/SettingsView.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
local React = require("@pkg/React")
local Sift = require("@pkg/Sift")

local Modal = require("@root/Modal/Modal")
local ModalPortal = require("@root/Modal/ModalPortal")
local ScrollingFrame = require("@root/Common/ScrollingFrame")
local SettingRow = require("@root/UserSettings/SettingRow")
local SettingsContext = require("@root/UserSettings/SettingsContext")
Expand All @@ -24,6 +26,11 @@ local function SettingsView()
end)
end, { settingsContext.settings })

local isModalShown, setIsModalShown = React.useState(true)
local onCloseModal = React.useCallback(function()
setIsModalShown(false)
end, {})

local children = {}
for index, setting in orderedSettings do
children[setting.name] = React.createElement(SettingRow, {
Expand Down Expand Up @@ -69,6 +76,15 @@ local function SettingsView()
Padding = theme.padding,
}),
}, children),

Sample = if isModalShown
then React.createElement(ModalPortal, {}, {
Modal = React.createElement(Modal, {
title = "Example",
onClose = onCloseModal,
}, {}),
})
else nil,
})
end

Expand Down

0 comments on commit ff2be27

Please sign in to comment.