root = Card([header, hiringStatus, openRoles, candidatePipeline, hiringMetrics, deptSplit, interviews, attrition, newRole])

header = CardHeader("Hiring Overview", "Live snapshot of recruiting and headcount")

hiringStatus = Card([headcountRow, timeToHireRow], "sunk")
headcountRow = TextContent("**Current headcount:** 342", "large")
timeToHireRow = TextContent("**Average time to hire:** 32 days", "default")

openRoles = Card([openRolesHeading, openRolesTable], "card")
openRolesHeading = Heading("Open roles", "h3")
openRolesTable = Table([roleCol, deptCol, reqCol])
roleCol = Col("Role", ["Senior Frontend Engineer", "Product Designer", "Data Analyst", "Customer Success Manager"])
deptCol = Col("Department", ["Engineering", "Design", "Data", "Revenue"])
reqCol = Col("Openings", [2, 1, 1, 3])

candidatePipeline = Card([pipelineHeading, pipelineChart], "card")
pipelineHeading = Heading("Candidates by pipeline stage", "h3")
pipelineChart = BarChart(["Applied", "Screened", "Interviewed", "Offered", "Hired"], [pipelineSeries])
pipelineSeries = Series("Candidates", [180, 96, 42, 18, 9])

hiringMetrics = Card([metricsHeading, metricsTable], "card")
metricsHeading = Heading("Hiring metrics", "h3")
metricsTable = Table([metricName, metricValue])
metricName = Col("Metric", ["Time to hire (avg)", "Offer acceptance rate", "Interviews scheduled this week"])
metricValue = Col("Value", ["32 days", "78%", "14"])

deptSplit = Card([deptHeading, deptChart], "card")
deptHeading = Heading("Headcount by department", "h3")
deptChart = HorizontalBarChart(["Engineering", "Product", "Design", "Data", "Revenue", "Operations"], [deptSeries])
deptSeries = Series("Headcount", [128, 34, 22, 18, 96, 44])

interviews = Card([interviewsHeading, interviewsList], "card")
interviewsHeading = Heading("Interviews scheduled this week", "h3")
interviewsList = ListBlock([intOne, intTwo, intThree, intFour])
intOne = ListItem("Senior Frontend Engineer", "Mon 10:00 — Ana Gomez (Engineering)")
intTwo = ListItem("Product Designer", "Tue 14:30 — Liam Chen (Design)")
intThree = ListItem("Data Analyst", "Wed 11:00 — Priya Nair (Data)")
intFour = ListItem("Customer Success Manager", "Thu 09:30 — Sam Ortiz (Revenue)")

attrition = Card([attritionHeading, attritionChart], "card")
attritionHeading = Heading("Attrition — last 6 months", "h3")
attritionChart = LineChart(["Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], [attritionSeries], "linear", "Month", "Leavers")
attritionSeries = Series("Leavers", [4, 6, 5, 8, 7, 5])

newRole = Card([newRoleHeading, newRoleForm], "card")
newRoleHeading = Heading("Open a new role", "h3")
newRoleForm = Form("new-role", roleFormButtons, [roleTitleField, roleDeptField, roleCountField])
roleTitleField = FormControl("Role title", roleTitleInput)
roleTitleInput = Input("role_title", "e.g. Backend Engineer")
roleDeptField = FormControl("Department", roleDeptSelect)
roleDeptSelect = Select("role_dept", [deptEng, deptProd, deptDesign, deptData, deptRev, deptOps], "Choose department")
deptEng = SelectItem("engineering", "Engineering")
deptProd = SelectItem("product", "Product")
deptDesign = SelectItem("design", "Design")
deptData = SelectItem("data", "Data")
deptRev = SelectItem("revenue", "Revenue")
deptOps = SelectItem("operations", "Operations")
roleCountField = FormControl("Number of openings", roleCountInput)
roleCountInput = Input("role_count", "1", "number")
roleFormButtons = Buttons([submitRoleBtn])
submitRoleBtn = Button("Create role", null, "primary")