Open zachy9 opened 3 years ago
There is no easy way (currently) to do that. Have a look at #107 which has similar ideas about that. Currently there is some adjustment done at the end of the rendering, after the whole HTML is finished. The function is resizeLayout
.
The base idea would be:
best
that selects left
for landscape mode, and top
for portrait mode.So I don't think this is not possible, but at the moment, it is just not done. I'am not an expert, and pretty busy, but I will try to have a look if there is a simple way to add this.
Thanks for the suggestions! I've been toying with the grid layout css to see if I can make it work but I'm new to grids.
And thanks for all your work on this library.
@zachy9 I had a similar issue.
I am using tailwind css as my base css framework lib, as such, I leveraged the css classes (sm:hidden / sm:block) to target device sizes (media queries), to render the specific layout per device size I need.
I actually only needed to render a desktop / laptop view and a mobile view, so dynamically passed the layout props "left" to render the PGN Viewer for desktop, then "top" to do so for mobile, relying on the css show / hide classes.
My implementation:
/* DESKTOP SPECIFIC */
<div className="hidden sm:block bg-white dark:bg-gray-800 shadow overflow-auto sm:rounded-lg m-1 p-4 mt-5">
<PGNViewer layout={"left"}>{games[0].pgn}</PGNViewer>
</div>
/* MOBILE SPECIFIC */
<div className="block sm:hidden bg-white shadow overflow-auto p-2">
<PGNViewer layout={"top"}>{games[0].pgn}</PGNViewer>
</div>
Reference:
Dynamic layout:
React component:
Hope that is helpful.
I use a 'left' layout (moves to the right of the board) and have been trying to get it to switch to a 'top' layout (moves underneath the board) when the parent div gets narrower.
Is there currently an easy way to do this?