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

Add support for multiple device and responsive design #73

Open
MikaelPorttila opened this issue Apr 9, 2021 · 2 comments
Open

Add support for multiple device and responsive design #73

MikaelPorttila opened this issue Apr 9, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@MikaelPorttila
Copy link

Hi,

A feature request for an already great tool:
The option to design for multiple device sizes and orientations at once and then the choice to export all the needed responsive styles.

@patak-dev
Copy link
Member

Thanks for your interest in the project! We discussed this feature a few times in the past. It would be very useful.
It is not that easy to add though, but let's use this issue to track future progress.

@patak-dev patak-dev added the enhancement New feature or request label Jun 16, 2021
@krekosiewicz
Copy link

@patak-dev
I'd like to work on this issue to improve my Vue.js skills, as I have barely used this framework in the past.

I've created a couple of mockups in Figma to ensure I correctly understand the scope, and to include some of my thoughts about responsiveness based on my past experience.

Screenshot from 2024-09-05 15-58-47

This is the default view. I've trimmed the top a bit and added tabs with two actions. Some elements are blurred, but in the final merge request, they should rather be display: none until a custom breakpoint is added. Apart from this toolbar, there should be no changes to the UI in non-responsive use cases.

In the top toolbar, there are two actions: one for adding an additional breakpoint, and another for switching between mobile and desktop orientation. I really like Tailwind's mobile-first approach; in my opinion, it saves time and results in fewer orphaned styles long-term. I'd like to set mobile-first as the default option.

We need to display an extra set of rules, such as:

// Device names
$mobile: 'mobile';
$tablet: 'tablet';
$smDesktop: 'small-desktop';
$desktop: 'desktop';
// dynamic 

// Breakpoints
$breakpoint-mobile: 420px;
$breakpoint-tablet: 668px;
$breakpoint-small-desktop: 992px;
$breakpoint-desktop: 1200px;
// dynamic 

// Media queries MOBILE FIRST
@mixin respond-to($breakpoint) {
  @if $breakpoint == $mobile {
    @media (min-width: $breakpoint-mobile) { @content; }
  } @else if $breakpoint == $tablet {
    @media (min-width: $breakpoint-tablet) { @content; }
  } @else if $breakpoint == $smDesktop {
    @media (min-width: $breakpoint-small-desktop) { @content; }
  } @else if $breakpoint == $desktop {
    @media (min-width: $breakpoint-desktop) { @content; }
  }
}

or

// Device names
$mobile: 'mobile';
$tablet: 'tablet';
$smDesktop: 'small-desktop';
$desktop: 'desktop';
// dynamic 

// Breakpoints
$breakpoint-mobile: 420px;
$breakpoint-tablet: 668px;
$breakpoint-small-desktop: 992px;
$breakpoint-desktop: 1200px;
// dynamic 

// Media queries DESKTOP FIRST
@mixin respond-to($breakpoint) {
  @if $breakpoint == $mobile {
    @media (max-width: $breakpoint-mobile) { @content; }
  } @else if $breakpoint == $tablet {
    @media (max-width: $breakpoint-tablet) { @content; }
  } @else if $breakpoint == $smDesktop {
    @media (max-width: $breakpoint-small-desktop) { @content; }
  } @else if $breakpoint == $desktop {
    @media (max-width: $breakpoint-desktop) { @content; }
  }
}

In fact, this is the first result when searching for "mixin, responsive, multiple devices." I’ve noticed that media queries often become problematic in commercial projects. I believe this approach is good enough to share with any Layoutit user, but if you know of a cleaner or more universal strategy to handle breakpoints, please let me know.

If the user creates a custom breakpoint, they should be able to set the width threshold in the leftbar or at the bottom of the view container (as vertical dimensions are less common, I'd like to ignore them in the first implementation).

This image shows where we can display the respond-to mixin (ideally, it should be suggested to place it in a separate file).
Screenshot from 2024-09-05 15-59-57

This image shows that breakpoints have been added and are being handled by the mixin from the previous screenshot.
Screenshot from 2024-09-05 16-00-17

futher improvements

App should have some sort of width validator/warning that will inform user if current breakpoint "overlapping" another one

The mockups are just PoC of how this feature can look like. I've reproduced app in Figma to make this raw roadmap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants