Open atdiar opened 6 months ago
Still wondering. TailwindCSS doesn't seem much different from applying CSS properties one by one which we can already do in a much more composable way in Go via the CSS Stylesheet API. In that case, reusable styles would simply be functions applied to ui elements.
Material is a no go as it requires preprocessing. Could use materialize although it might be a bit dated.
Would be perhaps relevant to build upon an implementation of classless CSS. Will require to create a component library. Once done for one platform, perhaps find ways to automatically translate layouts, etc. to other platform, turning everything into something 'responsive'.
https://chat.openai.com/share/6f90d95e-b154-45ba-99f5-1107bf71de61
The choice between em
, rem
, px
, and other units in CSS depends on design goals, accessibility considerations, and specific behavior desired for various elements. Here’s a general guideline on when and for what elements each unit is commonly used:
px
- Pixelsem
- Relative to the Font Size of the Elementem
is relative to the font size of its nearest parent. This makes em
units ideal for scalable, typographic designs where elements need to scale in relation to the text size of their parent element.rem
- Relative to the Font Size of the Root Elementrem
units are based on the font size of the root element (html
). They are used to provide consistent scaling across the document, making them useful for building consistent, accessible interfaces.%
- Percentagevw
, vh
, vmin
, vmax
Choosing the right unit often involves balancing design consistency, accessibility needs, and the dynamic nature of web content across different devices and user settings.
Breakpoint strategy in responsive design is crucial for adapting layouts to various screen sizes, ensuring both usability and accessibility. Here's a comprehensive strategy for utilizing breakpoints:
/* Base styles */
body {
font-size: 16px;
}
.container {
max-width: 1200px;
margin: auto;
}
nav ul {
display: flex;
}
/* Breakpoint for tablets */
@media (max-width: 768px) {
body {
font-size: 14px;
}
.container {
max-width: 600px;
}
nav ul {
display: block;
}
}
/* Breakpoint for mobile */
@media (max-width: 480px) {
body {
font-size: 12
As usual, we are going to reconsider everything from first principles in order to find out what the best course of action should be.
After having thouhgt a little about it, turns out that responsive design is synonymous with reactive style properties of the elements of a UI tree, where the reaction is triggered by a change in the viewport dimensions or the user-agent (interaction capabilities change depending on whether we are on mobile web or desktop web for instance). Could even be triggered by a viewport orientation change (on mobile for instance).
responsive design is synonymous with *reactive style properties
Given how the framework allows to have namespaced stylesheets, we can simply activate the relevant stylesheet that corresponds to a given breakpoint.
A grid is characterized by a number of columns and a number of rows. For a reactive grid, these numbers are functions of the viewport dimensions that are recomputed when the size of the viewport changes.
Some elements that might be fitting for a desktop environment might not be adequate for a mobile environment and vice versa. In which case, we need to be able to swap them depending on the user-agent.
Implementation
func On(uiprop string, condval Value, children ....*Element) func(*Element) *Element{
return func(e *Element) *Element {
e.Watch("ui", uiprop, e, NewMutationHandler(func(evt MutationEvent)bool{
evt.Origin().SetChildren(children....)
return false
}).RunASAP())
return e
}
}
We can implement a wrapper round the above that will watch a property that holds a value describing the type of responsive environment the document is in (for instance, could be ("ui", "display") ( and include the user-agent and/or information such as mobile, desktop, smalldisplay, medium display, large display, length, width, ...)
// Switch is an *Element modifier that applies to an element and allows to conditionally set its children
// based on the value of a property:
//
// Switch("ui","display").
// Case(String("small"), A).
// Case(String("large"), B).
// Case(String("medium"), C).
// Default(nil),
//
// In the above example, the children of the element will be set to A if the value of the property "display" is "small",
// to B if it is "large", to C if it is "medium" and to nothing if it is anything else.
// The Default method is used to set the children of the element when the property value does not match any of the cases.
// Example of a reactive datepicker Element implemented using the Switch modifier:
var smallDatepicker *Element // Reference to the small datepicker element, here just to provide a more realistic example
E(document.Div.WithID("uuid-datepicker"),
Switch("ui","display").
Case(String("small"), DatePickerSmall("uuid-dp-s", Ref(&smallDatepicker))).
Case(String("large"), DatePickerLarge("uuid-dp-xl"))).
Case(String("medium"), DatePickerMedium("uuid-dp-m")).
WithSharedData("date").
Default(nil),
)
/*
Important to note that the the value of "ui,display" is observed on the parent div of id "uuid-datepicker".
This is potentially the same value that is being set by the EnableResponsiveUI constructor option, i.e. the value
for the document "ui" property "display"
That should allow for the tree to be reactive to display changes.
*/
Re. Touch event handling https://chatgpt.com/share/b9669aaf-7857-4a83-9e4a-24237c1b4b95
Preamble
Wondering if it wouldn't be better to have a generic and customizable responsive design system So that creating for the mobile-web can automatically translate on desktop and vice versa.
It would probably involve the consideration of:
Layout and Structure
Navigation
Data Display
Forms and Inputs
Feedback and Notifications
Media and Icons
Miscellaneous
Material 3 (aka Material You)
Implementing Material Design 3: Key Considerations
1. Theming and Customization
2. Responsive Layouts
3. Components
Essential components with responsive and adaptable considerations:
4. Motion
5. Accessibility
6. Performance and Optimization
7. Development and Tooling
8. Documentation and Guidelines
9. Testing and Validation
Guidelines Not Obvious Before Reading Material Design Documentation:
Elevation and Shadow: Material Design uses elevation to imply hierarchy and focus. The use of shadows and elevation levels is more systematic and nuanced than merely adding drop shadows for aesthetic purposes.
Motion Provides Meaning: Animations and transitions aren't just for visual flair in Material Design; they are used to indicate relationships between elements, action outcomes, and spatial organization, guiding user attention in a meaningful way.
Adaptive Icons: Beyond the shape and size, adaptive icons in Material Design can dynamically change their appearance based on system settings or to better fit alongside other UI elements, enhancing visual harmony.
User-Generated Theming: Material Design 3, especially with Material You, emphasizes themes that adapt not just to device characteristics but also to user preferences, such as wallpaper colors, creating a personalized experience.
Component States: The detailed specification for how components should behave in different states (hover, focused, pressed, disabled) ensures a consistent and predictable user experience but might be more comprehensive than initially expected.
Layout Grids: The role of grids in Material Design extends beyond basic alignment; they establish consistent spacing and keylines, which are crucial for maintaining a harmonious layout across different screen sizes and orientations.
Dark Theme Considerations: Implementing a dark theme is not merely about inverting colors; Material Design provides specific guidance on color usage, elevation treatments, and component coloring to ensure readability and reduce eye strain in low-light conditions.
Understanding these nuanced guidelines can significantly enhance the usability and aesthetic of your applications, aligning them with Material Design principles for a cohesive and user-friendly experience.
(via chatgpt)