Comments (9)
@AnjaMis
Please, could you add the technical spec related to a new Modal
component, designed from scratch?
from dataverse-portal.
Thank you all for your valuable comments, I have updated my tech spec, I hope it's better now :) Please let me know again if I missed something or you have some other suggestions
from dataverse-portal.
Nice improvements! I think you forgot the children
prop, and also you can replace both classnames by a classes
object, as we made in some of our components, it's more flexible to apply style where we want :)
from dataverse-portal.
Technical Specification: Modal Component
Description
The Modal Component is a React-based, highly customizable, and reusable solution designed for displaying focused content in a modal overlay.
The component features a controlled modal behavior, meaning its visibility is determined by the parent component's state through the isOpen
prop. When the modal is open, users can view a clear representation of the content, enabling focused interactions.
Modal Component
Props
isOpen
(boolean, required): Controls the visibility of the modal. When set totrue
, the modal is open, and when set tofalse
, it's closed.onClose
(function, required): A callback function that closes the modal when the close button is clicked or when clicking outside the modal.closeOnEsc
(boolean, optional): If set totrue
, pressing the 'Esc' key will trigger the modal to close. Defaults totrue
.isCentered
(boolean, optional): If set totrue
, the modal will be vertically and horizontally centered on the screen. Defaults tofalse
.motionPreset
(string, optional): to choose a suitable animation preset for the modal transition. Defaults to a suitable animation preset.classes
(object, optional): An object containing CSS class names to apply custom styles to the modal and overlay elements.main
(string, optional): Apply custom styles to the modal content using this CSS class name.overlay
(string, optional): Apply custom styles to the background overlay behind the modal using this CSS class name.
children
(React Node, optional): The content to be displayed inside the modal.
Usage
- Integrate the
<Modal>
component into the application where needed to display content in a modal format. - Maintain a state variable, e.g.,
isModalOpen
, to track the open/closed state of the modal. - When the modal needs to be displayed, set the
isModalOpen
state totrue
. - Render the
<Modal>
component conditionally based on theisModalOpen
state. Pass the props (listed above) - Use JSX to define the content inside the
<Modal>
component. - When the modal is open, users can view the content inside the
<Modal>
. When they click the close button or outside the modal, the modal will be closed by calling theonClose
prop function, updating theisModalOpen
state tofalse
.
Note
This is just a preliminary suggestion. Most of the modal stylings can be done with CSS, however, if needed, some could be added as props.
from dataverse-portal.
@AnjaMis thank you for this detailed specification!
The problem you'll find here is that the design of this component leads to an overly specific result.
You've defined a mandatory hiddenItems
prop as being a list of "hidden" items: this is true for this feature, as we're trying to display hidden items through the modal.
But it's not always a question of hidden items as described here, but rather of "content" to be displayed to the user (which won't necessarily be an array of items).
Similarly, if we want to use this modal elsewhere, it's not certain that we need a title to display.
You can take a look at other libraries such as MUI or ChakraUi to see how to build this modal to make it generic š
from dataverse-portal.
@lolottetheclash good point! I have updated my previous comment now! :)
from dataverse-portal.
@AnjaMis thanks, that's a very detailed specification! š
In order to make it easier to write the specification, we can take a step back and discuss about the definition of the Modal, that influences how we orient the specification description.
Indeed, the modal might also be used to alert the user or invite him to perform a specific action. That additional definition helps to define it's functionalities by detaching it's usage from the context we primarily need (revealing hidden items).
The modal component would probably need a third parameter for it's JSX content. I think we need to define it even though we use the default React children
property.
Also, modal use to be displayed at the top of the App (e. g. our Notification component), mainly because of styling considerations.
You can achieve that using createPortal API.
from dataverse-portal.
Thx @AnjaMis :)
I think you must consider going a little bit further in the specification, especially regarding the way the modal behaves.
E.G. Should we close the modal on click outside?, on pressing escape button?, should we add a way to disable these options? How the user could customize the viewport's background behind the modal? ...
Don't hesitate to have a look at other UI libraries ;)
from dataverse-portal.
Hey team! Please add your planning poker estimate with Zenhub @fredericvilcot @0xLodz @AnjaMis @lolottetheclash
from dataverse-portal.
Related Issues (20)
- [Interact] Available cards HOT 1
- [Wallet] Available balance - Mobile
- [Portal] Button behaviour HOT 3
- Scroll bar design on Windows / Firefox HOT 1
- Update dataspace by zone HOT 1
- [Share Data] Select your data - Folder Drag & Drop HOT 3
- [Governance] Zone detail page - governance section HOT 1
- Share data page and stepper layout HOT 1
- [Share data] Select a storage service - `A local folder` general display - V2
- [Share data] Select a storage service - details of a service - V2 Ontology HOT 2
- [Resource referencing] Multi-Step Form with Stepper - V2 Mandatory fields HOT 3
- Wrong transaltion in Fill in metadata of Share my dataset HOT 1
- [Share data] Complete Tx - General display HOT 6
- [Share data] Complete Tx - Fee section HOT 4
- [Share data] Complete Tx - Tx transfered HOT 1
- TEST
- Production Deployment nĀ°1
- Test HOT 1
- Tag duplication inconsistency HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dataverse-portal.