Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui-core: add close button to pickers #773

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ui-core/src/components/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useEffect, useRef } from 'react';

import { X } from '@osrd-project/ui-icons';

Check warning on line 3 in ui-core/src/components/Modal.tsx

View workflow job for this annotation

GitHub Actions / build

Unable to resolve path to module '@osrd-project/ui-icons'

import { useModalPosition } from '../hooks/useModalPosition';
import useOutsideClick from '../hooks/useOutsideClick';

Expand Down Expand Up @@ -31,6 +33,9 @@
className="modal-content"
style={{ top: modalPosition.top, left: modalPosition.left }}
>
<button className="close-button" onClick={onClose}>
<X size="lg" />
</button>
{children}
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions ui-core/src/components/inputs/datePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';

import { Calendar as CalendarIcon } from '@osrd-project/ui-icons';

Check warning on line 3 in ui-core/src/components/inputs/datePicker/DatePicker.tsx

View workflow job for this annotation

GitHub Actions / build

Unable to resolve path to module '@osrd-project/ui-icons'
import cx from 'classnames';

import { type CalendarSlot } from '.';
import CalendarPicker, { type CalendarPickerPublicProps } from './CalendarPicker';
import useDatePicker from './useDatePicker';
import InputModal from '../../Modal';
import Input, { type InputProps } from '../Input';

type BaseDatePickerProps = {
Expand Down Expand Up @@ -69,7 +70,7 @@
statusWithMessage={statusWithMessage}
/>
</div>
{showPicker && (
<InputModal inputRef={inputRef} isOpen={showPicker} onClose={() => setShowPicker(false)}>
<div className="calendar-picker-wrapper">
<CalendarPicker
{...props.calendarPickerProps}
Expand All @@ -80,7 +81,7 @@
selectableSlot={selectableSlot}
/>
</div>
)}
</InputModal>
</div>
);
};
Expand Down
7 changes: 0 additions & 7 deletions ui-core/src/styles/inputs/datePicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@
}

.calendar-picker {
position: absolute;
width: fit-content;
border-radius: 0.5rem;
box-shadow:
0 0.813rem 0.938rem -0.438rem rgba(31, 27, 23, 0.1),
0 0.188rem 0.375rem rgba(31, 27, 23, 0.2);
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
@apply bg-white-100;

.calendar-navigation-btn {
width: 2rem;
Expand Down
1 change: 1 addition & 0 deletions ui-core/src/styles/inputs/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
@import './timePicker.css';
@import './tokenInput.css';
@import './tolerancePicker.css';
@import './modal.css';
33 changes: 33 additions & 0 deletions ui-core/src/styles/inputs/modal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1000;
}

.modal-content {
background-color: theme('colors.white.100');
border-radius: 0.5rem;
box-shadow:
0px 1px 0px rgba(255, 255, 255, 1) inset,
0px 4px 7px -3px rgba(24, 68, 239, 0.19),
0px 1px 3px rgba(49, 46, 43, 0.2);
position: absolute;

.close-button {
position: absolute;
top: 16px;
right: 16px;
color: theme('colors.grey.50');

&:hover {
color: theme('colors.grey.90');
}

&:active {
color: theme('colors.grey.20');
}
}
}
16 changes: 0 additions & 16 deletions ui-core/src/styles/inputs/timePicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,8 @@
display: none;
}

.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1000;
}

.modal-content {
background-color: #fff;
padding: 4.563rem;
border-radius: 0.313rem;
box-shadow:
0px 1px 0px rgba(255, 255, 255, 1) inset,
0px 4px 7px -3px rgba(24, 68, 239, 0.19),
0px 1px 3px rgba(49, 46, 43, 0.2);
position: absolute;
}

.time-picker-container {
Expand Down
14 changes: 0 additions & 14 deletions ui-core/src/styles/inputs/tolerancePicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
}

.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1000;

.tolerance-picker-section {
display: flex;
gap: 1rem;
Expand Down Expand Up @@ -56,14 +49,7 @@
}

.modal-content {
background-color: #fff;
padding: 1.25rem;
border-radius: 0.313rem;
box-shadow:
0px 1px 0px rgba(255, 255, 255, 1) inset,
0px 4px 7px -3px rgba(24, 68, 239, 0.19),
0px 1px 3px rgba(49, 46, 43, 0.2);
position: absolute;
}

.time-picker-container {
Expand Down
Loading