-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
670 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
local Root = script:FindFirstAncestor("rbxtheme") | ||
|
||
local getThemeColors = require(Root.getThemeColors) | ||
local types = require(Root.types) | ||
|
||
local function applyTheme(theme: types.ExtensionTheme, studio: Studio): string? | ||
local colors = getThemeColors(theme) | ||
local problems = {} | ||
|
||
if colors and colors.found then | ||
for name, color in colors.found do | ||
-- Discard the alpha component of the hexcode | ||
if #color - 1 > 6 then | ||
local colorNoAlpha = color:sub(1, 7) | ||
|
||
-- TODO: Blend colors with the background to get rid of the | ||
-- alpha component. That way we don't need to warn the user | ||
table.insert(problems, `{name} uses unsupported alpha value. Truncating {color} to {colorNoAlpha}`) | ||
|
||
color = colorNoAlpha | ||
end | ||
|
||
local success, result = pcall(function() | ||
studio[name] = Color3.fromHex(color) | ||
end) | ||
|
||
if not success then | ||
table.insert(problems, `Failed to set {name}: {result}`) | ||
end | ||
end | ||
end | ||
|
||
if #problems > 0 then | ||
local problemsStr = "" | ||
for index, problem in problems do | ||
problemsStr ..= `{index}. {problem}\n` | ||
end | ||
return `{theme.name} was applied, but not all colors were set:\n{problemsStr}` | ||
end | ||
end | ||
|
||
return applyTheme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
local Root = script:FindFirstAncestor("rbxtheme") | ||
|
||
local React = require(Root.Packages.React) | ||
local types = require(Root.types) | ||
local getLayoutOrder = require(Root.Components.getLayoutOrder) | ||
|
||
type PublishedExtension = types.PublishedExtension | ||
|
||
export type Props = { | ||
extensions: { PublishedExtension }, | ||
onView: (extension: PublishedExtension) -> (), | ||
LayoutOrder: number?, | ||
} | ||
|
||
local ACTION_BUTTON_WIDTH = 120 | ||
local PADDING = UDim.new(0, 8) | ||
|
||
local function ExtensionsList(props: Props) | ||
local children = { | ||
Layout = React.createElement("UIListLayout", { | ||
Padding = PADDING, | ||
SortOrder = Enum.SortOrder.LayoutOrder, | ||
}), | ||
} | ||
|
||
for i, extension in props.extensions do | ||
local isEven = i % 2 == 0 | ||
local latestVersion = if extension.versions then extension.versions[1] else nil | ||
|
||
children[extension.extensionName] = React.createElement("Frame", { | ||
LayoutOrder = i, | ||
BackgroundTransparency = if isEven then 1 else 0.2, | ||
BackgroundColor3 = Color3.fromRGB(100, 100, 100), | ||
BorderSizePixel = 0, | ||
AutomaticSize = Enum.AutomaticSize.Y, | ||
Size = UDim2.fromScale(1, 0), | ||
}, { | ||
Layout = React.createElement("UIListLayout", { | ||
SortOrder = Enum.SortOrder.LayoutOrder, | ||
FillDirection = Enum.FillDirection.Horizontal, | ||
VerticalAlignment = Enum.VerticalAlignment.Center, | ||
}), | ||
|
||
Padding = React.createElement("UIPadding", { | ||
PaddingTop = PADDING, | ||
PaddingRight = PADDING, | ||
PaddingBottom = PADDING, | ||
PaddingLeft = PADDING, | ||
}), | ||
|
||
Main = React.createElement("Frame", { | ||
LayoutOrder = getLayoutOrder(), | ||
Size = UDim2.fromScale(1, 0) - UDim2.fromOffset(ACTION_BUTTON_WIDTH, 0), | ||
AutomaticSize = Enum.AutomaticSize.Y, | ||
BackgroundTransparency = 1, | ||
}, { | ||
Layout = React.createElement("UIListLayout", { | ||
SortOrder = Enum.SortOrder.LayoutOrder, | ||
Padding = PADDING, | ||
}), | ||
|
||
Name = React.createElement("TextLabel", { | ||
LayoutOrder = getLayoutOrder(), | ||
AutomaticSize = Enum.AutomaticSize.XY, | ||
BackgroundTransparency = 1, | ||
Text = `{extension.displayName} v{latestVersion.version}`, | ||
TextSize = 16, | ||
Font = Enum.Font.GothamMedium, | ||
TextXAlignment = Enum.TextXAlignment.Left, | ||
TextYAlignment = Enum.TextYAlignment.Top, | ||
TextColor3 = Color3.fromRGB(255, 255, 255), | ||
TextTruncate = Enum.TextTruncate.AtEnd, | ||
}), | ||
|
||
Publisher = React.createElement("TextLabel", { | ||
LayoutOrder = getLayoutOrder(), | ||
Text = extension.publisher.publisherName, | ||
TextSize = 14, | ||
TextColor3 = Color3.fromRGB(200, 200, 200), | ||
AutomaticSize = Enum.AutomaticSize.XY, | ||
BackgroundTransparency = 1, | ||
Font = Enum.Font.GothamMedium, | ||
TextXAlignment = Enum.TextXAlignment.Left, | ||
TextYAlignment = Enum.TextYAlignment.Top, | ||
}), | ||
}), | ||
|
||
Action = React.createElement("TextButton", { | ||
LayoutOrder = getLayoutOrder(), | ||
Text = "View", | ||
TextSize = 14, | ||
TextColor3 = Color3.fromRGB(255, 255, 255), | ||
BorderSizePixel = 0, | ||
Font = Enum.Font.GothamMedium, | ||
Size = UDim2.fromOffset(ACTION_BUTTON_WIDTH, 0), | ||
AutomaticSize = Enum.AutomaticSize.Y, | ||
[React.Event.Activated] = function() | ||
props.onView(extension) | ||
end, | ||
}, { | ||
Padding = React.createElement("UIPadding", { | ||
PaddingTop = PADDING, | ||
PaddingRight = PADDING, | ||
PaddingBottom = PADDING, | ||
PaddingLeft = PADDING, | ||
}), | ||
|
||
Corner = React.createElement("UICorner", { | ||
CornerRadius = PADDING, | ||
}), | ||
}), | ||
}) | ||
end | ||
|
||
return React.createElement("Frame", { | ||
LayoutOrder = props.LayoutOrder, | ||
AutomaticSize = Enum.AutomaticSize.Y, | ||
Size = UDim2.fromScale(1, 0), | ||
BackgroundTransparency = 1, | ||
}, children) | ||
end | ||
|
||
return ExtensionsList |
Oops, something went wrong.