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

Extensible two-column layout for deck options #1255

Closed

Conversation

kleinerpirat
Copy link
Contributor

@kleinerpirat kleinerpirat commented Jun 26, 2021

I had another go at making the deck options responsive for wide screens.
(Previous attempts: #1210, #1212)

The task was to make this idea of mine work with the Svelte components. Here is the CodePen I created as a proof-of-concept.
I tried my best to keep the necessary changes at a minimum and make it extensible.

image
The grid layout takes effect when viewport width is >= 992px.

How the current approach works

  1. approximate size of each TitledContainer at runtime via amount of contained .row elements
  2. add up total amount of TitledContainer sizes with store lineCount
  3. calculate amount of rows needed to fit all elements on two columns

Why the extra effort with individual row spans?


Left: all elements span 1 row -> Big elements like "Advanced" create a lot of white space
Right: individual row spans reduce that white space significantly

Extra

  • set upper limit (currently 2rem) for h1 font-size with clamp function, because indefinite scaling with viewport width doesn't make much sense for the two-column layout.

I am not really happy with the way I implemented the lineCount store to get the total row span of all components. I'm sure @hgiesel knows of multiple better ways to allow child components to change a parent component's variable.
The addition to Container.svelte is a bit dirty, but I found it more elegant than to wrap the options in an extra div within DeckOptionsPage.svelte. Let me know if I should still go for that second option.

Tasks

  • Find more elegant way to add up total amount of TitledContainer sizes (lineCount) across components
  • Use more accurate and universal way to approximate size (e.g. offsetHeight of containing div)
    One issue is that the correct offsetHeight is not immediately available with onMount, probably due to rendering delay.

I don't have much faith in this getting merged because it feels a bit hacky. But I'd invite you to try it out and perhaps create something along these lines yourself (or guide me in the right direction), if you like the look of it.

Comment on lines 64 to 67
<script context="module">
import { writable } from "svelte/store";
export const lineCount = writable(0);
</script>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks failing because Prettier wants this all the way on top, but it's a hacky solution anyway - bound to get replaced.

Had forgotten to revert a change I did to show how it would look with fixed row spans.
+ Small code style tweak
Should satisfy the format check now.
Overlooked that one.
dae added a commit that referenced this pull request Jun 28, 2021
Alternative approach to #1255
@kleinerpirat
Copy link
Contributor Author

Damien's approach is much simpler and also better, as it is guaranteed not to waste any space. Time to close this one.

@kleinerpirat kleinerpirat deleted the deckoptions-two-columns branch June 28, 2021 13:22
dae added a commit that referenced this pull request Jun 29, 2021
Alternative approach to #1255

thanks to hkr for the margin fix!
dae added a commit that referenced this pull request Jun 29, 2021
Alternative approach to #1255

thanks to Hikaru and Henrik for the margin fix!
dae added a commit that referenced this pull request Jun 29, 2021
Alternative approach to #1255

thanks to Hikaru and Henrik for the margin fix, and Matthias for
the initial idea and prototypes!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant