Skip to content

Commit

Permalink
Wrapper Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
nightcycle committed Jul 9, 2024
1 parent ba32ef7 commit 5dd361e
Show file tree
Hide file tree
Showing 32 changed files with 1,667 additions and 44 deletions.
86 changes: 43 additions & 43 deletions scripts/compile/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,50 +210,50 @@ def write_wrapper(self) -> None:
]

for func in self.functions:
key = func['key']
if key != "":
for name in func["names"]:

lines += [
f'\nfunction Interface.{name}(): {camel_to_pascal(key)}{self.name}Wrapper',
'local maid = Maid.new()',
'local _fuse = ColdFusion.fuse(maid)',
'local _Value = _fuse.Value',

'local definition = {',
]
for param in func["parameters"]:
lines.append(f'{camel_to_pascal(param["name"])} = _Value('+param["default"]+'),')

lines += [
# key = func['key']
# if key != "":
for name in func["names"]:

lines += [
f'\nfunction Interface.{name}(): {camel_to_pascal(key)}{self.name}Wrapper',
'local maid = Maid.new()',
'local _fuse = ColdFusion.fuse(maid)',
'local _Value = _fuse.Value',

'local definition = {',
]
for param in func["parameters"]:
lines.append(f'{camel_to_pascal(param["name"])} = _Value('+param["default"]+'),')

lines += [
'}',
'local defaults: {[string]: unknown?} = {'
]
for param in func["parameters"]:
lines.append(f'{param['name']} = DEFAULTS.{camel_to_upper_snake(name)}.{camel_to_upper_snake(param['name'])},')

lines += [
'}',
'local defaults: {[string]: unknown?} = {'
]
for param in func["parameters"]:
lines.append(f'{param['name']} = DEFAULTS.{camel_to_upper_snake(name)}.{camel_to_upper_snake(param['name'])},')

lines += [
'}',
f'local inst: GuiObject = Source.{name}(',
]
def_params = []
for param in func["parameters"]:
def_params.append(f'definition.{camel_to_pascal(param["name"])}')

lines += [
",".join(def_params),
')',

'maid:GiveTask(inst.Destroying:Connect(function()',
'maid:Destroy()',
'end))',

f'local wrapper, cleanUp = Translators.ColdFusion.toWrapper("{camel_to_pascal(key)}{self.name}", inst, definition, defaults)',
'maid:GiveTask(cleanUp)',

'return wrapper',
'end',
]
f'local inst: GuiObject = Source.{name}(',
]
def_params = []
for param in func["parameters"]:
def_params.append(f'definition.{camel_to_pascal(param["name"])}')

lines += [
",".join(def_params),
')',

'maid:GiveTask(inst.Destroying:Connect(function()',
'maid:Destroy()',
'end))',

f'local wrapper, cleanUp = Translators.ColdFusion.toWrapper("{camel_to_pascal(key)}{self.name}", inst, definition, defaults)',
'maid:GiveTask(cleanUp)',

'return wrapper',
'end',
]

lines += [
'\nreturn Interface',
Expand Down
2 changes: 1 addition & 1 deletion sourcemap.json

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions src/Component/Button/Badge/Wrapper.luau
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,60 @@ local DEFAULTS = require(script.Parent:WaitForChild("Defaults"))
-- Interface
local Interface = {}

function Interface.new(): StyledBadgeWrapper
local maid = Maid.new()
local _fuse = ColdFusion.fuse(maid)
local _Value = _fuse.Value
local definition = {
OnClick = _Value(function() end),
Icon = _Value(Types.ImageData.new("")),
Label = _Value(""),
Count = _Value(nil),
TextColor = _Value(Color3.new()),
HoverColor = _Value(Color3.new()),
ErrorTextColor = _Value(Color3.new()),
ErrorBackgroundColor = _Value(Color3.new()),
Elevation = _Value(0),
SchemeType = _Value(Enums.SchemeType.Light),
FontData = _Value(Types.FontData.new(Font.fromEnum(Enum.Font.SourceSans), 14)),
Scale = _Value(1),
}
local defaults: { [string]: unknown? } = {
onClick = DEFAULTS.NEW.ON_CLICK,
icon = DEFAULTS.NEW.ICON,
label = DEFAULTS.NEW.LABEL,
count = DEFAULTS.NEW.COUNT,
textColor = DEFAULTS.NEW.TEXT_COLOR,
hoverColor = DEFAULTS.NEW.HOVER_COLOR,
errorTextColor = DEFAULTS.NEW.ERROR_TEXT_COLOR,
errorBackgroundColor = DEFAULTS.NEW.ERROR_BACKGROUND_COLOR,
elevation = DEFAULTS.NEW.ELEVATION,
schemeType = DEFAULTS.NEW.SCHEME_TYPE,
fontData = DEFAULTS.NEW.FONT_DATA,
scale = DEFAULTS.NEW.SCALE,
}
local inst: GuiObject = Source.new(
definition.OnClick,
definition.Icon,
definition.Label,
definition.Count,
definition.TextColor,
definition.HoverColor,
definition.ErrorTextColor,
definition.ErrorBackgroundColor,
definition.Elevation,
definition.SchemeType,
definition.FontData,
definition.Scale
)
maid:GiveTask(inst.Destroying:Connect(function()
maid:Destroy()
end))
local wrapper, cleanUp = Translators.ColdFusion.toWrapper("StyledBadge", inst, definition, defaults)
maid:GiveTask(cleanUp)
return wrapper
end

function Interface.onPrimary(): StyledBadgeWrapper
local maid = Maid.new()
local _fuse = ColdFusion.fuse(maid)
Expand Down
48 changes: 48 additions & 0 deletions src/Component/Button/Chip/Assist/Wrapper.luau
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,54 @@ local DEFAULTS = require(script.Parent:WaitForChild("Defaults"))
-- Interface
local Interface = {}

function Interface.new(): StyledAssistWrapper
local maid = Maid.new()
local _fuse = ColdFusion.fuse(maid)
local _Value = _fuse.Value
local definition = {
OnClick = _Value(function() end),
Text = _Value("Chip"),
Icon = _Value(nil),
TextColor = _Value(Color3.new()),
DisabledTextColor = _Value(Color3.new()),
IsEnabled = _Value(true),
Elevation = _Value(0),
SchemeType = _Value(Enums.SchemeType.Light),
FontData = _Value(Types.FontData.new(Font.fromEnum(Enum.Font.SourceSans), 14)),
Scale = _Value(1),
}
local defaults: { [string]: unknown? } = {
onClick = DEFAULTS.NEW.ON_CLICK,
text = DEFAULTS.NEW.TEXT,
icon = DEFAULTS.NEW.ICON,
textColor = DEFAULTS.NEW.TEXT_COLOR,
disabledTextColor = DEFAULTS.NEW.DISABLED_TEXT_COLOR,
isEnabled = DEFAULTS.NEW.IS_ENABLED,
elevation = DEFAULTS.NEW.ELEVATION,
schemeType = DEFAULTS.NEW.SCHEME_TYPE,
fontData = DEFAULTS.NEW.FONT_DATA,
scale = DEFAULTS.NEW.SCALE,
}
local inst: GuiObject = Source.new(
definition.OnClick,
definition.Text,
definition.Icon,
definition.TextColor,
definition.DisabledTextColor,
definition.IsEnabled,
definition.Elevation,
definition.SchemeType,
definition.FontData,
definition.Scale
)
maid:GiveTask(inst.Destroying:Connect(function()
maid:Destroy()
end))
local wrapper, cleanUp = Translators.ColdFusion.toWrapper("StyledAssist", inst, definition, defaults)
maid:GiveTask(cleanUp)
return wrapper
end

function Interface.primary(): StyledAssistWrapper
local maid = Maid.new()
local _fuse = ColdFusion.fuse(maid)
Expand Down
57 changes: 57 additions & 0 deletions src/Component/Button/Chip/Filter/Wrapper.luau
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,63 @@ local DEFAULTS = require(script.Parent:WaitForChild("Defaults"))
-- Interface
local Interface = {}

function Interface.new(): StyledFilterWrapper
local maid = Maid.new()
local _fuse = ColdFusion.fuse(maid)
local _Value = _fuse.Value
local definition = {
OnClick = _Value(function(isSelected: boolean) end),
IsInitiallySelected = _Value(false),
Text = _Value("Filter"),
TextColor = _Value(Color3.new()),
DisabledTextColor = _Value(Color3.new()),
FillTextColor = _Value(Color3.new()),
DisabledFillTextColor = _Value(Color3.new()),
DisabledFillColor = _Value(Color3.new()),
IsEnabled = _Value(true),
Elevation = _Value(0),
SchemeType = _Value(Enums.SchemeType.Light),
FontData = _Value(Types.FontData.new(Font.fromEnum(Enum.Font.SourceSans), 14)),
Scale = _Value(1),
}
local defaults: { [string]: unknown? } = {
onClick = DEFAULTS.NEW.ON_CLICK,
isInitiallySelected = DEFAULTS.NEW.IS_INITIALLY_SELECTED,
text = DEFAULTS.NEW.TEXT,
textColor = DEFAULTS.NEW.TEXT_COLOR,
disabledTextColor = DEFAULTS.NEW.DISABLED_TEXT_COLOR,
fillTextColor = DEFAULTS.NEW.FILL_TEXT_COLOR,
disabledFillTextColor = DEFAULTS.NEW.DISABLED_FILL_TEXT_COLOR,
disabledFillColor = DEFAULTS.NEW.DISABLED_FILL_COLOR,
isEnabled = DEFAULTS.NEW.IS_ENABLED,
elevation = DEFAULTS.NEW.ELEVATION,
schemeType = DEFAULTS.NEW.SCHEME_TYPE,
fontData = DEFAULTS.NEW.FONT_DATA,
scale = DEFAULTS.NEW.SCALE,
}
local inst: GuiObject = Source.new(
definition.OnClick,
definition.IsInitiallySelected,
definition.Text,
definition.TextColor,
definition.DisabledTextColor,
definition.FillTextColor,
definition.DisabledFillTextColor,
definition.DisabledFillColor,
definition.IsEnabled,
definition.Elevation,
definition.SchemeType,
definition.FontData,
definition.Scale
)
maid:GiveTask(inst.Destroying:Connect(function()
maid:Destroy()
end))
local wrapper, cleanUp = Translators.ColdFusion.toWrapper("StyledFilter", inst, definition, defaults)
maid:GiveTask(cleanUp)
return wrapper
end

function Interface.primary(): StyledFilterWrapper
local maid = Maid.new()
local _fuse = ColdFusion.fuse(maid)
Expand Down
58 changes: 58 additions & 0 deletions src/Component/Button/ElevatedButton/Wrapper.luau
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,64 @@ local DEFAULTS = require(script.Parent:WaitForChild("Defaults"))
-- Interface
local Interface = {}

function Interface.new(): StyledElevatedButtonWrapper
local maid = Maid.new()
local _fuse = ColdFusion.fuse(maid)
local _Value = _fuse.Value
local definition = {
OnClick = _Value(function() end),
Text = _Value("Button"),
Icon = _Value(nil),
TextColor = _Value(Color3.new()),
SurfaceColor = _Value(Color3.new()),
DisabledTextColor = _Value(Color3.new()),
DisabledSurfaceColor = _Value(Color3.new()),
ShadowColor = _Value(Color3.new()),
IsEnabled = _Value(true),
Elevation = _Value(0),
SchemeType = _Value(Enums.SchemeType.Light),
FontData = _Value(Types.FontData.new(Font.fromEnum(Enum.Font.SourceSans), 14)),
Scale = _Value(1),
}
local defaults: { [string]: unknown? } = {
onClick = DEFAULTS.NEW.ON_CLICK,
text = DEFAULTS.NEW.TEXT,
icon = DEFAULTS.NEW.ICON,
textColor = DEFAULTS.NEW.TEXT_COLOR,
surfaceColor = DEFAULTS.NEW.SURFACE_COLOR,
disabledTextColor = DEFAULTS.NEW.DISABLED_TEXT_COLOR,
disabledSurfaceColor = DEFAULTS.NEW.DISABLED_SURFACE_COLOR,
shadowColor = DEFAULTS.NEW.SHADOW_COLOR,
isEnabled = DEFAULTS.NEW.IS_ENABLED,
elevation = DEFAULTS.NEW.ELEVATION,
schemeType = DEFAULTS.NEW.SCHEME_TYPE,
fontData = DEFAULTS.NEW.FONT_DATA,
scale = DEFAULTS.NEW.SCALE,
}
local inst: GuiObject = Source.new(
definition.OnClick,
definition.Text,
definition.Icon,
definition.TextColor,
definition.SurfaceColor,
definition.DisabledTextColor,
definition.DisabledSurfaceColor,
definition.ShadowColor,
definition.IsEnabled,
definition.Elevation,
definition.SchemeType,
definition.FontData,
definition.Scale
)
maid:GiveTask(inst.Destroying:Connect(function()
maid:Destroy()
end))
local wrapper, cleanUp =
Translators.ColdFusion.toWrapper("StyledElevatedButton", inst, definition, defaults)
maid:GiveTask(cleanUp)
return wrapper
end

function Interface.primary(): StyledElevatedButtonWrapper
local maid = Maid.new()
local _fuse = ColdFusion.fuse(maid)
Expand Down
Loading

0 comments on commit 5dd361e

Please sign in to comment.