Pick a start and an end on two months, or a preset such as Last 7 days, with an optional comparison period.
Growth
Period
Period
//
//
November 2026
Sun
Mon
Tue
Wed
Thu
Fri
Sat
December 2026
Sun
Mon
Tue
Wed
Thu
Fri
Sat
Nov 3 – Dec 2, 2026 · 30 days
Signups2,116+2.5% vs the period before
Active teams2,098-0.5% vs the period before
Issues closed2,080-0.5% vs the period before
import{UiSchema}from"@effect/ui"import{Html}from"@effect/ui/html"import*as stylex from"@stylexjs/stylex"import{Schema}from"effect"import{ addDays,DateRange, epochDay, previousPeriod }from"./ui/uicontext/components/dates/DateMath.ts"import{DateRangePicker}from"./ui/uicontext/components/DateRangePicker.ts"import{ sx }from"./ui/uicontext/components/Sx.ts"import{ color, font, radius, space }from"./ui/uicontext/components/tokens.stylex.ts"// A dashboard's period. Presets apply at once; a range picked on the calendar applies with Apply,// so the numbers reload once. Turn on the comparison to see the change against the period before.const today ="2026-12-02"const styles = stylex.create({page:{display:"grid",gap: space.xl,inlineSize:"min(100%, 40rem)"},bar:{display:"flex",flexWrap:"wrap",alignItems:"end",justifyContent:"space-between",gap: space.lg},heading:{margin:0,fontSize: font.xl,fontWeight:600,letterSpacing:"-0.02em"},stats:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(9rem, 1fr))",gap: space.md},stat:{display:"grid",gap: space.xs,padding: space.lg,borderWidth:1,borderStyle:"solid",borderColor: color.line,borderRadius: radius.lg,backgroundColor: color.panel},statLabel:{fontSize: font.sm,color: color.muted},statValue:{fontSize: font.xxl,fontWeight:600,fontVariantNumeric:"tabular-nums",letterSpacing:"-0.02em"},up:{fontSize: font.sm,color: color.success,fontVariantNumeric:"tabular-nums"},down:{fontSize: font.sm,color: color.danger,fontVariantNumeric:"tabular-nums"},flat:{fontSize: font.sm,color: color.muted},})constMessage=UiSchema.TaggedEnum({PickedPeriod:{value:DateRange,compare:Schema.Boolean}})// made-up daily numbers that stay the same for a day, so the totals change only with the periodconst daily =(day: number,salt: number)=>40+((day *2654435761+ salt *97)%61)const total =(range:DateRange,salt: number)=>{let sum =0for(let day =epochDay(range.start); day <=epochDay(range.end); day++) sum +=daily(day, salt)return sum}const metrics =[{label:"Signups",salt:1},{label:"Active teams",salt:2},{label:"Issues closed",salt:3},]exportconstAnalyticsPeriod=Html.component({name:"AnalyticsPeriod",model:Schema.Struct({period:DateRange,compare:Schema.Boolean}),message:Message,}).make({init:()=>({period:{start:addDays(today,-29),end: today },compare:true}),update:{PickedPeriod:($,{ value, compare })=> $.evolve({period: value, compare })},view:(h,{ period, compare })=>{const number =newIntl.NumberFormat("en-US")const percent =newIntl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:1,signDisplay:"exceptZero"})return h.div.attrs(sx(styles.page)).children( h.div.attrs(sx(styles.bar)).children( h.h3.attrs(sx(styles.heading)).children("Growth"),DateRangePicker(h,{props:{label:"Period",hideLabel:true,value: period, today,locale:"en-US",offerCompare:true, compare,max: today },onEmit:{Picked:({ value,compare: against })=>Message.PickedPeriod({ value,compare: against !==null})},}),), h.div.attrs(sx(styles.stats)).children( metrics.map((metric)=>{const now =total(period, metric.salt)const before =total(previousPeriod(period), metric.salt)const change = before ===0?0:(now - before)/ beforereturn h.div.key(metric.label).attrs(sx(styles.stat)).children( h.span.attrs(sx(styles.statLabel)).children(metric.label), h.span.attrs(sx(styles.statValue)).children(number.format(now)), compare && h.span.attrs(sx(change >0? styles.up: change <0? styles.down: styles.flat)).children(`${percent.format(change)} vs the period before`),)}),),)},})