Comments (6)
Hi @blaiseludvig!
Thanks for your like this library at first of all.
We have thought about problems like this before. I think muuri does not force the style to encapsulate into a new class and expose it to the outside in this case, but chooses the way to let the user define the style by himself. Perhaps he wants to give the user a full and flexible usage. ruuri hopes to design concept that is consistent with muuri, which will avoid many problems with the development of muuri in the future.
However, for this question, maybe you can consider trying this method: set the style of the container through the CSS class selector .ruuri-draggable-item
on the parent node.
Hope it helps you!
from ruuri.
Thanks for your response!
I might have been unclear in the suggestion in my previous message. Sorry about that!
Your method would unfortunately not work in my case because I'm using multiple DraggableGrid
s, and I need to be able to set the widths of the items individually for each grid, but the .ruuri-draggable-item
class targets every DraggableGrid
.
I came up with two solutions to this problem.
-
The
.ruuri-draggable-item
element could be optionally passed in through the props, just like therenderItem
. The downside to this approach is that it complicates the library code a bit. -
Give
DraggableGrid
an optional prop of typeReact.ComponentPropsWithoutRef<"div">
that gets merged into the props of the.ruuri-draggable-item
elements. This approach produces a flexible API, and it's easy to implement.
I'm interested in making a PR if you like one of these solutions!
from ruuri.
Thanks for your recommendation!
It's time to expand api for more flexible, I prefers the idea that add props getter function.
There are two APIs designed.
New API design prototype below:
// New API for getItemProps
type GetItemProps<T> = (itemData: T, index: number) => Partial<HTMLAttributes<HTMLDivElement>>
// New API for getItemContentProps
type GetItemContentProps<T> = (itemData: T, index: number) => Partial<HTMLAttributes<HTMLDivElement>>
// in interface DraggableGridProps
interface DraggableGridProps<T> {
...
data: T[]
...
+ getItemProps?: GetItemProps<T>
+ getItemContentProps?: GetItemContentProps<T>
...
}
How about this solution? @blaiseludvig
from ruuri.
Looks good to me! Glad I was able to help.
from ruuri.
hah! Thanks for your work, PR is welcome :)
from ruuri.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from ruuri.
Related Issues (10)
- Compiling issues with React^17.0.2 HOT 2
- export 'useInsertionEffect' (imported as 'React') was not found in 'react' HOT 5
- Problem starting HOT 5
- Dynamically resize items HOT 20
- No animation when items are added/removed/showing/hiding HOT 3
- Grid works incorrectly without `<React.StrictMode>` HOT 1
- Support "propsToData" property like muuri-react lib
- The value of dragEnabled property can't update using hook HOT 3
- The element did not rerender HOT 2
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 ruuri.