1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

(quality) Refacto tooltip

This commit is contained in:
vincent 2022-09-16 17:58:19 +02:00 committed by Sylvain
parent 9742558cfa
commit 945428e71c
9 changed files with 63 additions and 36 deletions

View File

@ -63,7 +63,7 @@ export const AbstractFormItem = <TFieldValues extends FieldValues>({ id, label,
<>
{(label && !inLine) && <div className='form-item-header'>
<p onClick={handleLabelClick}>{label}</p>
{tooltip && <div className="item-tooltip">
{tooltip && <div className="fab-tooltip">
<span className="trigger"><i className="fa fa-question-circle" /></span>
<div className="content">{tooltip}</div>
</div>}
@ -71,7 +71,7 @@ export const AbstractFormItem = <TFieldValues extends FieldValues>({ id, label,
<div className='form-item-field'>
{inLine && <div className='form-item-header'><p>{label}</p>
{tooltip && <div className="item-tooltip">
{tooltip && <div className="fab-tooltip">
<span className="trigger"><i className="fa fa-question-circle" /></span>
<div className="content">{tooltip}</div>
</div>}

View File

@ -6,6 +6,7 @@ import { FabButton } from '../base/fab-button';
import { User } from '../../models/user';
import { FabStateLabel } from '../base/fab-state-label';
import OrderLib from '../../lib/order';
import { ArrowClockwise } from 'phosphor-react';
interface OrderItemProps {
order?: Order,
@ -47,7 +48,18 @@ export const OrderItem: React.FC<OrderItemProps> = ({ order, currentUser }) => {
<p>{order?.user?.name || ''}</p>
</div>
}
<p className="date">{FormatLib.date(order.created_at)}</p>
<div className="date">
<span>{t('app.shared.store.order_item.created_at')}</span>
<p>{FormatLib.date(order.created_at)}
<div className="fab-tooltip">
<span className="trigger"><ArrowClockwise size={16} weight="light" /></span>
<div className="content">
{t('app.shared.store.order_item.last_update')}<br />
{FormatLib.date(order.updated_at)}
</div>
</div>
</p>
</div>
<div className='price'>
<span>{t('app.shared.store.order_item.total')}</span>
<p>{FormatLib.price(order.state === 'cart' ? order.total : order.paid_total)}</p>

View File

@ -356,7 +356,7 @@ const Orders: React.FC<OrdersProps> = ({ currentUser, onError }) => {
<button onClick={removeFilter('user')}><X size={16} weight="light" /></button>
</div>}
{filters.period_from && <div className='features-item'>
<p>{filters.period_from} - {filters.period_to}</p>
<p>{filters.period_from} {'>'} {filters.period_to}</p>
<button onClick={removeFilter('period')}><X size={16} weight="light" /></button>
</div>}
</div>

View File

@ -30,6 +30,7 @@
@import "modules/base/fab-popover";
@import "modules/base/fab-state-label";
@import "modules/base/fab-text-editor";
@import "modules/base/fab-tooltip";
@import "modules/base/labelled-input";
@import "modules/calendar/calendar";
@import "modules/cart/cart-button";

View File

@ -0,0 +1,29 @@
.fab-tooltip {
position: relative;
cursor: help;
.trigger i { display: block; }
.content {
position: absolute;
top: 0;
right: 0;
display: none;
width: max-content;
max-width: min(75vw, 65ch);
padding: 1rem;
background-color: var(--information-lightest);
color: var(--information);
border: 1px solid var(--information);
border-radius: var(--border-radius);
font-size: 14px;
font-weight: normal;
line-height: 1.2em;
z-index: 1;
& > span { display: block; }
a {
color: var(--gray-hard);
text-decoration: underline;
}
}
&:hover .content { display: block; }
}

View File

@ -15,36 +15,6 @@
cursor: pointer;
&::first-letter { text-transform: uppercase; }
}
.item-tooltip {
position: relative;
cursor: help;
.trigger i { display: block; }
.content {
position: absolute;
top: 0;
right: 0;
display: none;
width: max-content;
max-width: min(75vw, 65ch);
padding: 1rem;
background-color: var(--information-lightest);
color: var(--information);
border: 1px solid var(--information);
border-radius: var(--border-radius);
font-size: 14px;
font-weight: normal;
line-height: 1.2em;
z-index: 1;
& > span { display: block; }
a {
color: var(--gray-hard);
text-decoration: underline;
}
}
&:hover .content { display: block; }
}
}
&.is-hidden {
display: none;

View File

@ -6,7 +6,7 @@
margin-left: 1.5rem;
}
.item-tooltip .content {
.fab-tooltip .content {
max-width: min(75vw, 30ch);
}
}

View File

@ -36,7 +36,20 @@
}
p { @include text-sm; }
}
.date { @include text-sm; }
.date {
& > span {
@include text-xs;
color: var(--gray-hard-light);
}
p {
display: flex;
@include text-sm;
.fab-tooltip {
margin-left: 1rem;
color: var(--information);
}
}
}
.price {
flex: 0 1 30%;
display: flex;

View File

@ -564,6 +564,8 @@ en:
order_item:
total: "Total"
client: "Client"
created_at: "Order creation"
last_update: "Last update"
state:
cart: 'Cart'
in_progress: 'Under preparation'