-
Notifications
You must be signed in to change notification settings - Fork 19
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
[Idea v2] Scompose elements files in real atomic elements #26
Comments
Yeah that makes sense. I will work on that for v2. |
About that i think we will need another folders level like |
Broke out files much more in fe25860. |
@jonathanharrell I think this issue is not completed yes. We missed something big. I think we have to make a hiq core that provide a default configration. But if i import just a component, that component should have his own configuration that read varibles from core (if i'm importing it) and if i don't want the core global settings i should be able to use that components and change is configuration. Right now HIQ is too much monolitc. Take iotaCSS components and elements as example. Each component can live alone with his CSS configuration API, reading global core settings if exist, or just read his local configuration/customisation: |
Note that As an example, I can import
If the user has defined So our variables are functioning differently than sass variables. By default, HiQ does not actually define any variables. This is to take advantage of the fallback system that native CSS variables provide. Of course, if I want to, I can comment in the entire |
I'm talking about decoupling internal variables from ”public" variables. As you said, if i'm using another component/framework that define We need to isolate private component variables from "public variables". Take this example: Somewhere in the project: :root {
--hiq-button-border-radius: 20px;
--hiq-button-font-weight: 700;
} inside our button {
--buttonRadius: var(--hiq-button-border-radius, 0);
--buttonFontWeight: var(--hiq-button-font-weight, 400);
border-radius: var(--buttonRadius);
font-weight: var(--buttonFontWeight);
} By this way public CSS api are decoupled from the component. If we need a refactor we can just change internal variables (not exposed to the users) without breaking changes. |
Nice – yeah that makes sense. |
@jonathanharrell We can also be sure that no other variables with the same name can override our PS: Do you really understand my terrible english? :D |
Yeah that makes sense, although I want to make it possible to use HiQ with browsers that don't support CSS variables. Currently, we can use PostCSS to compute variables at build time, but only if they are defined on the root. There is no way to do this with variables that are defined within any other scope. For now, I think something like this would be better:
We just reference variables defined on Eventually, when IE11 usage is down to an insignificant number, we can change to something more like your example. And yes, I can understand your English. :) Code examples help me the most to quickly understand your points. Thanks for your feedback! |
By this way you will not decouple variables. |
True, but for now I think supporting IE11 is more important. Eventually, we can refactor the way you suggested. |
Wait, we can precompile variables when we build hiq.css. If someone are importing just a component it will probably have a custom postcss configuration. If they want to support ie11 they can simply set it in their postcss configuration. With my proposal we can cover both use cases :) |
Not sure how exactly that would would work. If someone is using postcss-custom-properties (the plugin that most closely follows the spec), it is not possible to compute variables that are defined anywhere other than |
FYI, here is the section of the new documentation I have been working on about providing fallbacks: Custom Property FallbacksIf you are supporting older browsers that do not support custom properties, you can run your css through PostCSS and use the PostCSS custom properties plugin. This will compute the custom properties at compile time. Note that if you do this, you will lose some of the benefits of custom properties, including the ability to dynamically change them with JavaScript or override them within scoped selectors or media queries. To preserve custom properties for the browsers that do support them, configure the PostCSS custom properties plugin like this: module.exports = {
plugins: [
// other plugins here
require('postcss-custom-properties')({
preserve: true
})
]
} This will result in both the original custom property and the computed property being included in the final css output: button {
background-color: hsl(210, 100%, 50%);
background-color: var(--gray-lighter);
} The custom property is included second and, therefore, will override the static value if the browser supports custom properties. |
@jonathanharrell So we can switch to postcss-css-variables that allow variables declaration inside any selector like the original spec and allow us to achieve better modularity. |
Ok I will try that out and do some cross-browser testing to make sure it works. |
Looks like currently there is a parsing error with postcss-css-variables that prevents it from working properly. I will have to stick with postcss-custom-properties for now. Will need to save this refactoring for a future version once the postcss-css-variable issue is resolved, as I think usability with IE11 and older version of Edge is more important at this time. |
Hi @jonathanharrell how are you :) Any news about this issue? |
Hi @equinusocio, thanks for checking in. Unfortunately nothing has been done to address the issue in the postcss-css-variables plugin. I still want to support IE11 at this point so cannot make the move towards decoupled component variables quite yet. Possibly we could create a parallel version which takes this step, or wait until IE11 usage further declines. |
Can you enter the issue link? |
@jonathanharrell Tell me if you need help o want to exchange some ideas |
Thanks @equinusocio I plan to work more on this towards the end of this year/beginning of next year. Feel free to send along any ideas you have. |
Locally scoped custom properties are now supported in v3.0.0: https://github.com/jonathanharrell/hiq/releases/tag/v3.0.0. HiQ is now dropping support for Internet Explorer. |
Hi @jonathanharrell, what do you think about break up elements files to real single components?
What i mean is that actually the
forms.css
files contains all elements style and i think that we should have a specific file for each element likeinput.pcss
,checkbox.pcss
,radio.pcss
,progress.pcss
etc.. likebuttons.pcss
andcode.pcss
are.By this way we follow the atomic design principles and fix code will be more easy.
The text was updated successfully, but these errors were encountered: