-
Notifications
You must be signed in to change notification settings - Fork 104
feat: Add Box Widget #7324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: Add Box Widget #7324
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8adb2f7
feat: Add Box Widget
hjpalpha 303446f
typo
hjpalpha 481eb4e
moverino
hjpalpha eb1f120
Update Box.lua
hjpalpha 96aeda0
Merge branch 'main' into box-widget
hjpalpha 7e8508a
right padding default as 2em
hjpalpha d2c5a9c
as per modules sync
hjpalpha 07d6a7f
Update stylesheets/commons/Miscellaneous.scss
hjpalpha 49c0315
Update Miscellaneous.scss
hjpalpha b4b7aae
Update Miscellaneous.scss
hjpalpha 4472bd4
Update Box.lua
hjpalpha 50f68ad
Update Box.lua
hjpalpha cc850da
Update Box.lua
hjpalpha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,57 @@ | ||
| --- | ||
| -- @Liquipedia | ||
| -- page=Module:Widget/Basic/Box | ||
| -- | ||
| -- Please see https://github.com/Liquipedia/Lua-Modules to contribute | ||
| -- | ||
|
|
||
| local Lua = require('Module:Lua') | ||
|
|
||
| local Array = Lua.import('Module:Array') | ||
| local Class = Lua.import('Module:Class') | ||
|
|
||
| local HtmlWidgets = Lua.import('Module:Widget/Html/All') | ||
| local Widget = Lua.import('Module:Widget') | ||
|
|
||
| ---@class BoxProps | ||
| ---@field children Renderable[]|Renderable | ||
| ---@field maxWidth string? | ||
| ---@field paddingLeft string? | ||
| ---@field paddingBottom string? | ||
| ---@field paddingRight string? | ||
| ---@field width string? | ||
| ---@field height string? | ||
|
|
||
| ---@class Box: Widget | ||
| ---@operator call(BoxProps): Box | ||
| ---@field props BoxProps | ||
| local Box = Class.new(Widget) | ||
|
|
||
| ---@return Widget|Renderable | ||
| function Box:render() | ||
| local children = self.props.children | ||
| if not Array.isArray(children) then | ||
| return self.props.children | ||
| end | ||
| ---@cast children -Renderable | ||
|
|
||
| return HtmlWidgets.Div{ | ||
| css = {['max-width'] = self.props.maxWidth}, | ||
| children = Array.map(children, function(child) | ||
| return HtmlWidgets.Div{ | ||
| classes = {'template-box'}, | ||
| css = { | ||
| ['padding-left'] = self.props.paddingLeft, | ||
| ['padding-bottom'] = self.props.paddingBottom, | ||
| ['padding-right'] = self.props.paddingRight, | ||
| width = self.props.width, | ||
| height = self.props.height, | ||
| overflow = self.props.height and 'hidden' or nil, | ||
| }, | ||
| children = child, | ||
| } | ||
| end) | ||
| } | ||
| end | ||
|
|
||
| return Box |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.