File tree Expand file tree Collapse file tree
routes/docs/components/Calendar Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' layerchart ' : patch
3+ ---
4+
5+ fix(Calendar): Pass ` cellSize ` to children snippet (useful when responsive)
Original file line number Diff line number Diff line change 4343 */
4444 tooltipContext? : TooltipContextValue ;
4545
46- children? : Snippet <[{ cells: CalendarCell [] }]>;
46+ children? : Snippet <[{ cells: CalendarCell []; cellSize : [ number , number ] }]>;
4747 } & Omit <
4848 RectPropsWithoutHTML ,
4949 ' children' | ' x' | ' y' | ' width' | ' height' | ' fill' | ' onpointermove' | ' onpointerleave'
117117 </script >
118118
119119{#if children }
120- {@render children ({ cells })}
120+ {@render children ({ cells , cellSize })}
121121{:else }
122122 {#each cells as cell }
123123 <Rect
Original file line number Diff line number Diff line change 183183 </Chart >
184184 </div >
185185</Preview >
186+
187+ <h2 >Html</h2 >
188+
189+ <Preview {data }>
190+ <div class =" h-[200px] p-4 border rounded-sm" >
191+ <Chart
192+ {data }
193+ x =" date"
194+ c =" value"
195+ cScale ={scaleThreshold ().unknown (' transparent' )}
196+ cDomain ={[25 , 50 , 75 ]}
197+ cRange ={[
198+ ' var(--color-primary-100)' ,
199+ ' var(--color-primary-300)' ,
200+ ' var(--color-primary-500)' ,
201+ ' var(--color-primary-700)' ,
202+ ]}
203+ padding ={{ top : 13 }}
204+ >
205+ {#snippet children ({ context })}
206+ <Layer type =" html" >
207+ <Calendar start ={firstDayOfYear } end ={lastDayOfYear } tooltipContext ={context .tooltip }>
208+ {#snippet children ({ cells , cellSize })}
209+ {#each cells as cell }
210+ <div
211+ class =" absolute p-px"
212+ style:left =" {cell .x }px"
213+ style:top =" {cell .y }px"
214+ style:width =" {cellSize [0 ]}px"
215+ style:height =" {cellSize [1 ]}px"
216+ onpointermove ={(e ) => context .tooltip ?.show (e , cell .data )}
217+ onpointerleave ={(e ) => context .tooltip ?.hide ()}
218+ >
219+ <div
220+ class =" w-full h-full rounded-sm"
221+ style:background-color ={cell .color === ' transparent'
222+ ? ' rgb(0 0 0 / 5%)'
223+ : cell .color }
224+ ></div >
225+ </div >
226+ {/each }
227+ {/ snippet }
228+ </Calendar >
229+ </Layer >
230+
231+ <Tooltip .Root >
232+ {#snippet children ({ data })}
233+ <Tooltip .Header value ={data .date } format =" day" />
234+
235+ {#if data .value != null }
236+ <Tooltip .List >
237+ <Tooltip .Item
238+ label =" value"
239+ value ={data .value }
240+ format =" integer"
241+ valueAlign =" right"
242+ />
243+ </Tooltip .List >
244+ {/if }
245+ {/ snippet }
246+ </Tooltip .Root >
247+ {/ snippet }
248+ </Chart >
249+ </div >
250+ </Preview >
You can’t perform that action at this time.
0 commit comments