Giter Site home page Giter Site logo

bonsaicss / bonsai.css Goto Github PK

View Code? Open in Web Editor NEW
371.0 13.0 23.0 934 KB

A Utility Complete CSS Framework for less than 45kb (8kB Gzipped) -

Home Page: https://www.bonsaicss.com/

License: MIT License

JavaScript 4.42% HTML 40.52% CSS 55.06%
css css-framework responsive custom-properties utility-classes

bonsai.css's People

Contributors

c-lodder avatar ciar4n avatar dependabot[bot] avatar dgrammatiko avatar laoneo avatar yvesh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bonsai.css's Issues

--text-c on other elements

Hey @ciar4n and @C-Lodder,

you can currently set the heading (h1-h6) color with the color class helpers (.white, .blue etc.), but not on other elements. What do you think about extending the list slightly with some inline elements?

At least for me span / b / i and maybe code / mark could make sense, for example <span class="green">Green Text</span>

span, i, /*..*/ {
  color: var(--text-c, inherit);
}

Or how about another class combination like (.accent.primary) for text color (.color.primary)?

Thank you!

[Idea] Support size better, like small?

Hey @ciar4n,

I know you want to keep it as lightweight as possible, but there are multiple cases where helpers for sizing may be useful (to keep it consistent through multiple elements). For example currently the button spacing is quite "hardcoded":

  padding-right: 28px;
  padding-left: 28px;
  margin: .5rem .5rem .5rem 0;
  padding: 10px 12px;

Do you see a way to make this more dynamic (like moving the spacing stuff to variables)?

Or maybe (that's a big maybe), better supporting constructions like:

<small><button>..</button></small>

small button {
   /* lower spacing etc. */
}

An alternate would be classes, like .btn-small, .btn-lg - But this wouldn't be as dynamic and only focused on button elements :-/

What do you think?

Thanks,
Yves

Dark mode

What would be the most idiomatic way to add a dark mode switch in Bonsai? It's easy to add a dark-mode class, overwrite some variables from src/variables.css and toggle it on body with e.g. a checkbox. However that approach does not allow for css transitions. Any hints?

Trying Bonsaicss

Hi.

I want to start using Bonsai but I have some problem:

<div style="--fx --fd:row --jc:center --ai:center;"></div>

<div id="container"></div>

where:

#container {
    display: flex;
    /* establish flex container */
    flex-direction: row;
    /* make main axis horizontal (default value) */
    justify-content: center;
    /* center items horizontally, in this case */
    align-items: center;
    /* center items vertically, in this case */
}

for my understanding must have the same meaning, but is not working.

Because an internal div with id="box" and style:

.box {
     width: 300px;
     margin: 5px;
    text-align: center;
}

Is not centered horizontally with Bonsai

What I'm doing wrong?

.button class

Hey @ciar4n,
can we have a .button (or .btn whatever) class, just like we have with .tag? (Would make it easier to style links etc. as buttons) or is this too much? ;)
Thanks!

[Idea] Architecture: Atoms + Molecules

I am really enjoying using Bonsai in Svelte with my own custom helper classes to style molecules. That's where I got this idea. It fits nicely with Atomic design methodology.

Atoms (Vars) + Molecules (Classes) = ⚡

Atoms: At this level Bonsai has a lot to offer (base, helpers, and utility complete CSS).
Molecules: Little to offer. There are helper classes (.group) which style at molecule level. It would be great to offer more helper classes to set more than one property or to unset or override styles without repeating vars. This would become a separate module (i.e., molecule.css).

We can also borrow ideas from other frameworks.
Atomizer uses Atoms with a few helper classes:
https://github.com/acss-io/atomizer

--fg (flex-grow) not implemented?

Hey @ciar4n,
flex-grow seems not to be implemented (at least when i check the dist version of bonsai.css) - it's mentioned in the documentation (utilities section) though.

Missing code:

[style*="--fg:"] {
    flex-grow: var(--fg) !important;
}

Thanks,
Yves

docs?

Is there a repo for the docs?

I spotted a few references to bedrock in the docs and a lot of errors in the headers

Several Improvements

Hi, I like the concept of bonsai.css very much. Thank you for developing it.

If anyone is interested, I fixed some issues, and added a few things.
https://markusgritsch.github.io/bonsai.css/myindex.html
https://markusgritsch.github.io/bonsai.css/dist/mybonsai.css

image
The switch is an <input type="checkbox" role="switch">

image
The progress and (continuously spinning) busy indicator are new, the input range is a bit tweaked.

image image
The descender cropping and the height of the <select> is fixed.

Despite being disabled="", buttons still reacted to hover and clicking. This is now fixed.

image
Radio buttons properly display the focus border now and check boxes use an SVG check mark because the tick glyph was rendered black on my iPhone 6.

image
image
The grid layout can now be used without class="grid" and I added the grid-auto-flow property to be able to have a responsive auto flow direction.

image image
I added the bullet styling from the markdown book.css.

The @media rule now also affects printing, since printing a page styled for a phone does not look appealing.

The basic grid layouting was missing the xl @media rule.

Some other minor fixes.

Feel free to add some or all changes to your excellent bonsai.css framework.

Redundant styles cursor and cursor:hover

Hi, I don't understand when the 2nd rule would be useful
in case we define --cur and we hover this element we will see the defined cursor

AFIK defined cursor is only shown while we hover the element.
What is the reason for defining cursor property for :hover?

[style*="--cur:"] {
cursor: var(--cur) !important;
}
[style*="--cur:"]:hover {
cursor: var(--cur, var(--cursor));
}

I see there is a fallback value in the second rule.
But It has not any effect:
if the attr style has --cur defined It will show --cur
otherwise the rule does not match and var(--cursor) is not used

Thanks

[Issue] block-quote issues (collection)

Some issues using the blockquote:

  • Currently block quote styles are not easily overridable ("only" by changing the border-left property, some --color helper would be nice).
  • Top and bottom padding is too much (half or 10px instead of 16px would be better) -> imho
  • Background color is fixed to #fff; (Is there any reason to set it at all?)
  • Maybe make it usable with size helper (--x), not sure
blockquote {
  border-left: 4px solid var(--primary);
  background-color: #fff;
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  font-style: italic;
}

Default font-size, weight and line-height as CSS variables

Hey @ciar4n,

i feel the basic font-size, line-height and weight in _body.css should be CSS variables too. Would fit into the general scheme and makes overriding them easier, especially because other elements with rem are related to it.

  font-size: 15px;
  line-height: 1.6;
  font-weight: 400;

to

  font-size: var(--text-size, 15px);
  line-height: var(--text-line-height, 1.6);
  font-weight: var(--text-weight, 400);

You used --text as prefix for the other font related settings, so I used it in this example too.

What do you think?

--shadow is not really box-shadow

Hey @ciar4n,

in the documentation (Utilities) --shadow is described as box-shadow. But it's more a helper for a shadow without any customizations.

What do you think about adding a separate helper for box-shadow? --bs is already taken.

Sample usage:

--box: 0 0 0 2px var(--primary) inset;

or

--boxs: 0 0 0 2px var(--primary) inset;

Accessibility helpers

How about adding some accessibility classes (like .sr-only mostly) to bonsai.css?

[Feature] Add class to unstyle default styling

Hi,

Every now and then there's need to add classes for unstyling elements.
Like this:

.button-icon {
  border: unset;
  box-shadow: unset;
}

If we add support for .unstyle class there'll be no need to unset/override styles and it'll come handy.
For example:

.button:not(.unstyle), button:not(.unstyle) {
  ...
}

Descenders of characters (bottom of 'g', 'y', 'j', 'p') is chopped off in <select> elements

Using Chrome:

descenders

I've worked around this by adding the following to my custom.css:

select { line-height: inherit; }

Although there may be nicer ways in the source e.g. remove select from the following?

.button, button, input[type=button], input[type=checkbox], input[type=radio], input[type=range], input[type=submit], select { line-height: 1em; cursor: pointer; white-space: nowrap; }

Great project btw, many thanks.

Non intiutive utility naming

I nice to have one utility for each css to use it with different responsive prefixes,
When I want to use bonsai.css utilities I can't guess whats the utility name for the property I want to use.
I think it'd be better to have utilities with the same name as each property

For example if have this a div with this style in the clasic way I'd VSC autocomplete and copy&paste compatibility from stackoverflow

border: 1px solid black;
box-shadow: 2px 2px 0px red;

Then if I'd like to make something more especific for responsive

border: 1px solid black;
box-shadow: 2px 2px 0px red;
--border-md: 4px solid black;
--box-shadow-md: 4px 4px 0px red

I've implemented this change

│ bonsai-utilities.min.css │ 30.83 kB │ 4.96 kB │ Original
│ bonsai-utilities.min.css │ 30.50 kB │ 4.34 kB │ Utilities renamed and removed non resposive

│ bonsai.min.css │ 47.92 kB │ 8.09 kB │ Original
│ bonsai.min.css │ 47.07 kB │ 7.96 kB │ Utilities renamed and removed non resposive

[Issue] PayPal Button

Maybe the .input and input settings are too generic?

Just tried integrating a PayPal Button (Type doesn't matter) with bonsai.css enabled. Especially because the official paypal markup is weird (to keep it polite).

    <input type="image" name="submit"
    src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif"
    alt="Donate">

This results in a 100% width unreadable image with a border etc. What do you think does that need fixing from bonsai side?

Special cases aren't special enough to break the rules?

Buttons had lost the color

image

As you can see in the demo page buttons have not colors. It was not the case with version from september

Question

Hello, I'm here to ask someone to tell me how/why to use this library. I want to give it a try but I can't figure out the advantages 😕.

After some test I ended up with something like this to make a card

<div style="--maxw:400px; --p:0; --br:5px;">...</div>

but how this this can be considered different from classic inline style which doesn't require any lib?

<div style="max-width:400px; padding:0; border-radius:5px">...</div>

Each time I have a card I have to copy/paste the whole style attribute over and over, and if I have to change the style of the card I have to do a find/replace and change all the occurrence :(. Also i have to create a class anyway when I need to handle pseudo elements and pseudo selectors.

Can some explain me the difference/advantages?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.