Module:Tabs

From Zelda Dungeon Wiki
Revision as of 06:39, June 22, 2020 by Locke (talk | contribs) (WIP - converting T2D)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Want an adless experience? Log in or Create an account.

Documentation for this module may be created at Module:Tabs/doc

local TabContainer = {}
TabContainer.__index = TabContainer

function TabContainer.new( args )
  local obj = {
    id = args.id,
    content = args[1],
    tabsTop = args.top,
    tabsLeft = args.left,
    args = args
  }

  return setmetatable( obj, TabContainer )
end

function TabContainer:render()
  local container = mw.html.create( 'div' )
    :attr( 'id', self.id )
    :addClass( 'tabtarget box tabs2d' )
  if self.args.width then container:css( 'width', self.args.width .. 'px' ) end
  if self.args.height then container:css( 'height', self.args.height .. 'px' ) end
  if self.tabsLeft then
    container:addClass( 'hastabsleft' )
    container:css( 'margin-left', (self.args.vtabwidth or '60') .. 'px' )
    container:wikitext( self.tabsLeft )
  end
  if self.tabsTop then
    container:wikitext( self.tabsTop )
  end
  container:wikitext( self.content )
  container:tag( 'div' )
    :css( 'clear', 'both' )

  return tostring( container )
end

local TabSet = {}
TabSet.__index = TabSet

function TabSet.new( args )
  local obj = {
    args = args
  }

  return setmetatable( obj, TabSet )
end

function TabSet:render()
  local container = mw.html.create( 'div' )
  -- TODO
  return tostring( container )
end

local Tab = {}
Tab.__index = Tab

function Tab.new( args )
  local obj = {
    args = args
  }

  return setmetatable( obj, Tab )
end

function Tab:render()
  local container = mw.html.create( 'div' )
  -- TODO
  return tostring( container )
end

local TabContent = {}
TabContent.__index = TabContent

function TabContent.new( args )
  local obj = {
    args = args
  }

  return setmetatable( obj, TabContent )
end

function TabContent:render()
  local container = mw.html.create( 'div' )
  -- TODO
  return tostring( container )
end

local p = {}

p.TabContainer = TabContainer
p.TabSet = TabSet
p.Tab = Tab
p.TabContent = TabContent

function p.tabs( frame )
  local tabs = TabContainer.new( frame.args )
  return tabs:render()
end

function p.tabset( frame )
  local tabset = TabSet.new( frame.args )
  return tabset:render()
end

function p.tab( frame )
  local tab = Tab.new( frame.args )
  return tab:render()
end

function p.content( frame )
  local content = TabContent.new( frame.args )
  return content:render()
end

return p