Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

[FR] Implement border-styles? #4

Open
MaxBazarov opened this issue Nov 18, 2019 · 8 comments
Open

[FR] Implement border-styles? #4

MaxBazarov opened this issue Nov 18, 2019 · 8 comments

Comments

@MaxBazarov
Copy link
Contributor

https://spectrum.chat/puzzle-tokens/general/implement-border-styles~e2d7feb9-dc5b-4f8b-a8c5-aab6c5609e6a

I'm creating border variations, and have noticed that the CSS attribute "border-style" is not implemented. Is this planned? Specifically looking to implement the following border styles, in addition to the "solid" default:
dashed
dotted
double
Thanks!

Mike Bronner
@mikebronner

@MaxBazarov MaxBazarov changed the title Implement border-styles? [FR] Implement border-styles? Nov 18, 2019
@mikebronner
Copy link
Contributor

mikebronner commented Nov 18, 2019

I have come up with the following solutions for styled borders:

  • dashed: dash is 4 x border-width, gap is 4x border-width
  • dotted: dash is 1 x border-width, gap is 1 x border-width
    Since we have no control over dashes and dots in CSS, I took the values that Safari uses. However, I could see other system having control of this, so using two non-existing CSS values (but not LESS variables!) would make a lot of sense. perhaps something like:
.Borders Dashed {
    border-width: 1px;
    border-style: dashed;
    border-dash: 4px;
    border-gap: 4px;
}

.Borders Dotted {
    border-width: 1px;
    border-style: dashed;
    border-dash: 1px;
    border-gap: 1px;
}

As for double-borders, I didn't see a native way of doing it, so I faked it using 3 borders, using a white border as the gap. That isn't accurate, of course, as it should be transparent, but I wasn't sure how to accomplish that. If you have a better implementation, please go for it! :)

            @outerWidth: ((@width - (@width / (@width / 2))) / (@width / 4));
            @gapWidth: (@outerWidth + (@width / 4));
            @innerWidth: (@outerWidth + @gapWidth);

            .Borders .Double .@{width} .@{colorKey} .@{variant} {
                border-width: unit(@innerWidth, px);
                border-color: ~"@{colors-@{colorValue}-@{variant}}";
                border-position: inside;
            }
            .Borders .Double .@{width} .@{colorKey} .@{variant} {
                border-width: unit(@gapWidth, px);
                border-color: white;
                border-position: inside;
            }
            .Borders .Double .@{width} .@{colorKey} .@{variant} {
                border-width: unit(@outerWidth, px);
                border-color: ~"@{colors-@{colorValue}-@{variant}}";
                border-position: inside;
            }

Let me know if this helps. Would be glad to continue the discussion if you have concerns. :)

@mikebronner
Copy link
Contributor

Here's a rendered style output using the double-border code above:

Screen Shot 2019-11-18 at 8 13 08 AM

@MaxBazarov
Copy link
Contributor Author

Thanks for information! I will follow this way.

@MaxBazarov
Copy link
Contributor Author

Added support for
border-style: dotted;
border-style: dashed;
in 6.3.0 update

@mikebronner
Copy link
Contributor

mikebronner commented Nov 26, 2019

@MaxBazarov Thanks for implementing this. I am having some issues with the dotted style not applying the correct dash-length. In dotted the dash-length and the gap-length should be the same. It looks like the dash-length is hard-coded to 1px at the moment?

Screen Shot 2019-11-26 at 10 11 39 AM

Also, the dashed borders appear to implement the dotted style. Instead they should be rendered with the gap and dash being 3 x width each, as shown in the gray example:

Screen Shot 2019-11-26 at 10 15 05 AM

@MaxBazarov
Copy link
Contributor Author

MaxBazarov commented Nov 26, 2019 via email

@mikebronner
Copy link
Contributor

Until then, instead of hard-coding it, could you base it on the border-width attribute? Then when you implement dash- and gap-length attributes, if they aren't provided, fall back on border-width, and if that isn't provided, default to 1? I will see if I can't get a PR put together for this. :)

@MaxBazarov
Copy link
Contributor Author

@mikebronner Please check the latest updates. Now I base on border-width.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants