@displaycoffee/common 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -68,7 +68,7 @@ Neither file outputs any CSS on its own, so they're safe to `@use` in any styles
68
68
 
69
69
  #### mixins
70
70
 
71
- - **Layout** - `flex-layout`, `gap-width`, `grid-layout`, `position`, `position-fill`, `sizing`.
71
+ - **Layout** - `flex-layout`, `gap-width`, `grid-layout`, `margin-trim`, `position`, `position-fill`, `sizing`.
72
72
  - **Responsive** - `respond($breakpoint, $rule: 'min-width')` wraps `@content` in a media query. Unitless breakpoints get `px`.
73
73
  - **Text** - `ellipsis`, `line-clamp`, `text-decoration`, `placeholder`.
74
74
  - **Images and icons** - `object-fit`, `icon-sizing`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@displaycoffee/common",
3
3
  "description": "Sass functions and mixins, React hooks, utility functions, design token generation, and Vite helpers shared by every project.",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "type": "module",
6
6
  "author": "displaycoffee",
7
7
  "license": "ISC",
@@ -151,6 +151,21 @@
151
151
  -webkit-line-clamp: $lines;
152
152
  }
153
153
 
154
+ // Mixin to space text elements and the direct children of $selector, removing the last child's bottom margin
155
+ // Example: @include margin-trim(20px);
156
+ @mixin margin-trim($spacing, $selector: '.margin-trim', $selectors: (p, h1, h2, h3, h4, h5, h6), $selectors-children: (div, fieldset, figure, section)) {
157
+ $margin-trim-selectors: list.join($selectors, (), $separator: comma);
158
+ @each $element in $selectors-children {
159
+ $margin-trim-selectors: list.append($margin-trim-selectors, '#{$selector} > #{$element}', $separator: comma);
160
+ }
161
+ #{$margin-trim-selectors} {
162
+ margin: 0 0 $spacing 0;
163
+ }
164
+ #{$selector} > *:last-child {
165
+ margin-bottom: 0;
166
+ }
167
+ }
168
+
154
169
  // Image / object fit properties
155
170
  @mixin object-fit($position, $fit) {
156
171
  object-position: $position;