mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: optimize style of credit note details. feat: optimize global style checkbox of the application.
72 lines
1.5 KiB
JavaScript
72 lines
1.5 KiB
JavaScript
import React from 'react';
|
|
import classNames from 'classnames';
|
|
|
|
import 'style/components/Details.scss';
|
|
|
|
const DIRECTION = {
|
|
VERTICAL: 'vertical',
|
|
HORIZANTAL: 'horizantal',
|
|
};
|
|
|
|
const DetailsMenuContext = React.createContext();
|
|
const useDetailsMenuContext = () => React.useContext(DetailsMenuContext);
|
|
|
|
/**
|
|
* Details menu.
|
|
*/
|
|
export function DetailsMenu({
|
|
children,
|
|
direction = DIRECTION.VERTICAL,
|
|
textAlign,
|
|
minLabelSize,
|
|
className,
|
|
}) {
|
|
return (
|
|
<div
|
|
className={classNames(
|
|
'details-menu',
|
|
{
|
|
'details-menu--vertical': direction === DIRECTION.VERTICAL,
|
|
'details-menu--horizantal': direction === DIRECTION.HORIZANTAL,
|
|
[`align-${textAlign}`]: textAlign,
|
|
},
|
|
className,
|
|
)}
|
|
>
|
|
<DetailsMenuContext.Provider value={{ minLabelSize }}>
|
|
{children}
|
|
</DetailsMenuContext.Provider>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Detail item.
|
|
*/
|
|
export function DetailItem({ label, children, name, align, className }) {
|
|
const { minLabelSize } = useDetailsMenuContext();
|
|
|
|
return (
|
|
<div
|
|
className={classNames(
|
|
'detail-item',
|
|
{
|
|
[`detail-item--${name}`]: name,
|
|
[`align-${align}`]: align,
|
|
},
|
|
className,
|
|
)}
|
|
>
|
|
<div
|
|
style={{
|
|
'min-width': minLabelSize,
|
|
}}
|
|
class="detail-item__label"
|
|
>
|
|
{label}
|
|
</div>
|
|
<div class="detail-item__content">{children}</div>
|
|
</div>
|
|
);
|
|
}
|