@coveord/plasma-mantine
Version:
A Plasma flavoured Mantine theme
54 lines (53 loc) • 1.56 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { factory, Group, Text, useProps, useStyles } from '@mantine/core';
import dayjs from 'dayjs';
const defaultProps = {
label: 'Last update:',
formatter: (time)=>dayjs(time).format('h:mm:ss A')
};
export const LastUpdated = factory((props, ref)=>{
const { formatter, label, time, classNames, className, styles, style, vars, unstyled, ...others } = useProps('PlasmaLastUpdated', defaultProps, props);
const resolvedTime = time ?? dayjs().valueOf();
const getStyles = useStyles({
name: 'LastUpdated',
classes: {},
props,
className,
style,
classNames,
styles,
unstyled,
vars
});
const stylesApiProps = {
classNames,
styles
};
return /*#__PURE__*/ _jsx(Group, {
justify: props.justify,
ref: ref,
...getStyles('root', {
className,
style,
...stylesApiProps
}),
...others,
children: /*#__PURE__*/ _jsxs(Text, {
size: "xs",
...getStyles('label', {
className,
style,
...stylesApiProps
}),
children: [
label,
/*#__PURE__*/ _jsx("span", {
role: "timer",
children: formatter(resolvedTime)
})
]
})
});
});
LastUpdated.displayName = 'LastUpdated';
//# sourceMappingURL=LastUpdated.js.map