Skip to content

Add StyleSheet Wrapper - #74

Open
gaymeowing wants to merge 31 commits into
ffrostfall:mainfrom
gaymeowing:styling
Open

gaymeowing wants to merge 31 commits into
ffrostfall:mainfrom
gaymeowing:styling

Conversation

@gaymeowing

@gaymeowing gaymeowing commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #69
Closes #67

local dark = fluid.style_sheet("Dark", ReplicatedStorage):tokens {
	Primary = Color3.fromRGB(208, 188, 255),
	PrimaryHover = Color3.fromRGB(193, 172, 241),
}

local light = fluid.style_sheet("Light", ReplicatedStorage):tokens {
	Primary = Color3.fromRGB(103, 80, 164),
	PrimaryHover = Color3.fromRGB(118, 98, 173),
}

local sheet = fluid.style_sheet("Main", ReplicatedStorage)
	:derive(dark)
	:tokens {
		Radius = UDim.new(0, 8),
		Fade = TweenInfo.new(0.15),
	}
	:query "Wide" {
		MinSize = Vector2.new(400, 0),
	}
	
sheet:rule "TextButton.primary" {
	BackgroundColor3 = "$Primary",
	TextSize = 16,
	_transitions = {
		_default = TweenInfo.new(0.1),
		BackgroundColor3 = "$Fade",
	},
	_queries = {
		Wide = { TextSize = 20 },
		PreferredInputTouch = { TextSize = 24 },
	},
	sheet:pseudo "UICorner" {
		CornerRadius = "$Radius",
	},
}
:rule "TextButton.primary:Hover" {
	BackgroundColor3 = "$PrimaryHover",
	_priority = 1,
}

local dark_mode = true

fluid.root(function()
	fluid.create "ScreenGui" {
		fluid.create "TextButton" {
			Text = "Toggle theme",
			sheet:tags { "primary" },
			Activated = function()
				if dark_mode then
					sheet:underive(dark):derive(light)
				else
					sheet:underive(light):derive(dark)
				end
				dark_mode = not dark_mode
			end,
		},
		Parent = Players.LocalPlayer.PlayerGui,
		sheet:link(),
	}
end)

gaymeowing and others added 19 commits September 18, 2026 20:15
Signed-off-by: quaywinn <62822174+gaymeowing@users.noreply.github.com>
* remove hydrate (its just bind)
* export is_signal from the instances types.luau (so it can be used in my style sheet wrapper thingy)
* make PropertiesFor accept intsersection types, mainly for use with fake generic constraints
* make the properties table start off as an actual table, so each property set doesnt have to go through methods
* use readindexers instead of indexers on the table types created by PropertiesFor
* remove empty table from PropertiesFor
* add a type function for getting an array of read only property indexers (this is so my style sheets wrapper branch doesnt have to duplicate the table)
* rename first argument of bind to instance because inst is weird
* add style_sheet:underive()
* add style_sheet:pseudo()
* properly type style queries (i was stupid!!!)
* add required name & parent arguments to the constructor
* clean up comments
* freeze style_sheet prototype table
@gaymeowing
gaymeowing marked this pull request as draft September 28, 2026 17:21
…for rule specific queries to be created

* add type checking for pseudo instance class names
* add verification for StyleRule selectors using a type function
@gaymeowing
gaymeowing marked this pull request as ready for review September 30, 2026 00:12
@gaymeowing

Copy link
Copy Markdown
Contributor Author

didn't include tests because im planning on addressing tests when i bother with #72

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StyleSheet wrappers

2 participants