0.0.4 • Published 1 year ago

yearrecord v0.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

yearrecord

A react component that displays data for each day of the year

install

npm install yearrecord

use

In a React project, you can use it like this:

import YearRecord from "yearrecord"

function App() {

  return (
    <>
      <YearRecord
        themeColor="green"
        tooltipTitileFunc={item => `${item.year}年${item.month}月${item.day}日, ${item.data}次浏览`}
      ></YearRecord>
    </>
  )
}

export default App

then you will see: image

API

API of YearRecord

proptypedefault valuedescription
itemWidthstring“10px”width of div of the single day record
itemHeightstring"10px"height of div of the single day record
itemBorderRadiusstring"3px"border-radius of the div of the single day record
gridRowGapstring"3px"row gap, used in grid layout
gridColumnGapstring"3px"column gap, used in grid layout
yearnumbercurrent yearyear of the data
dataArrayrandom generatethe data to display, it's format is up to the prop compact. If compact === true, data is an Array of length n, and the i-th item is the data of month i+1, the length of month data is up to the count of days of that month, then format of a single day record is: {yaer: number, month: number, day:number, data: number}; if compact === falsedata will be an Array of length n, it conatins n single day records. In other words, data is a 2-d array if compact === true, else data is a 1-d array.
themeColorstring"#39d353"a string representing a color which can be used in css, sunch as: red, rgb(0,0,0), #eee, etc.
tooltipTitileFuncfunction_ => "tooltip title"this function accept a single day record object as it's parameter, and return a string which will be used as the tooltip title.
tooltipTitlePlacementstring"top"the placement of the tooltip title, it is one of ["top", "bottom", "left", "right"]
compactbooleanfalseif compact===true, then there will be no gap among months, and the format of data need to be changed.

API of MonthRecord

The props of MonthRecord is almost the same as YearRecord, because the props of the later are from the former, in other words, the most props of YearRecord will be directly passed to MonthRecord.The only prop MonthRecord has more than YearRecord is month:

proptypedefault valuedescription
monthnumbercurrent monthit will be displayed as a Chinese string below the component, such as "7月"
compactbooleanfalseif true, the component will ignore prop month, and display nothing below itself.

API of Tooltip

proptypedefault valuedescription
titlestring""tooltip title
placementstring"top"the same as yearrecord
0.0.2

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.1

1 year ago