From 202ead1626530e0c65f41019eefc67bb462d1844 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Thu, 8 Jan 2026 20:34:28 -0600 Subject: [PATCH] feat: mixin offset-content --- dist/tools/x-offset-content.css | 1 + dist/tools/x-offset-content.demo.css | 1 + src/lib/_imports/_partials/figure.hbs | 16 +++++--- src/lib/_imports/objects/o-offset-content.css | 37 ++++++++++--------- .../objects/o-offset-content/config.yml | 3 ++ .../o-offset-content/o-offset-content.hbs | 13 +++++++ .../objects/o-offset-content/readme.md | 10 +++++ src/lib/_imports/tools/x-offset-content.css | 37 +++++++++++++++++++ .../_imports/tools/x-offset-content.demo.css | 24 ++++++++++++ .../tools/x-offset-content/config.yml | 5 +++ .../_imports/tools/x-offset-content/readme.md | 14 +++++++ .../x-offset-content/x-offset-content.hbs | 14 +++++++ 12 files changed, 152 insertions(+), 23 deletions(-) create mode 100644 dist/tools/x-offset-content.css create mode 100644 dist/tools/x-offset-content.demo.css create mode 100644 src/lib/_imports/objects/o-offset-content/config.yml create mode 100644 src/lib/_imports/objects/o-offset-content/o-offset-content.hbs create mode 100644 src/lib/_imports/objects/o-offset-content/readme.md create mode 100644 src/lib/_imports/tools/x-offset-content.css create mode 100644 src/lib/_imports/tools/x-offset-content.demo.css create mode 100644 src/lib/_imports/tools/x-offset-content/config.yml create mode 100644 src/lib/_imports/tools/x-offset-content/readme.md create mode 100644 src/lib/_imports/tools/x-offset-content/x-offset-content.hbs diff --git a/dist/tools/x-offset-content.css b/dist/tools/x-offset-content.css new file mode 100644 index 000000000..758c6bfbc --- /dev/null +++ b/dist/tools/x-offset-content.css @@ -0,0 +1 @@ +/*! @tacc/core-styles 2.52.0+ | MIT | github.com/TACC/Core-Styles */ \ No newline at end of file diff --git a/dist/tools/x-offset-content.demo.css b/dist/tools/x-offset-content.demo.css new file mode 100644 index 000000000..200e1ca43 --- /dev/null +++ b/dist/tools/x-offset-content.demo.css @@ -0,0 +1 @@ +/*! @tacc/core-styles 2.52.0+ | MIT | github.com/TACC/Core-Styles */.x-offset-content--left,.x-offset-content--right{--offset-distance:12vw;--buffer:calc(var(--global-space--grid-gap)*2);max-width:85%}.x-offset-content--right{float:right;margin-left:var(--buffer);margin-right:calc(var(--offset-distance)*-1)}.x-offset-content--right+.x-offset-content--right{clear:right}.x-offset-content--left{float:left;margin-left:calc(var(--offset-distance)*-1);margin-right:var(--buffer)}.x-offset-content--left+.x-offset-content--left{clear:left} \ No newline at end of file diff --git a/src/lib/_imports/_partials/figure.hbs b/src/lib/_imports/_partials/figure.hbs index 78752272d..b65046525 100644 --- a/src/lib/_imports/_partials/figure.hbs +++ b/src/lib/_imports/_partials/figure.hbs @@ -1,14 +1,18 @@
{{#if use-image-wide}} - {{> @img large=true wide=true }} + {{> @img large=true wide=true class=img-class }} {{else if use-image-tall}} - {{> @img large=true tall=true }} + {{> @img large=true tall=true class=img-class }} {{else}} - {{> @img }} + {{> @img class=img-class }} {{/if}}
- I am a <figcaption> within a <figure>. - {{> @message tag="span" type="warning" scope="inline" - content="I may be wider than image. If so, should I wrap?" }} + {{#if caption}} + {{{ caption }}} + {{else}} + I am a <figcaption> within a <figure>. + {{> @message tag="span" type="warning" scope="inline" + content="I may be wider than image. If so, should I wrap?" }} + {{/if}}
diff --git a/src/lib/_imports/objects/o-offset-content.css b/src/lib/_imports/objects/o-offset-content.css index 004d8560d..a3700dac9 100644 --- a/src/lib/_imports/objects/o-offset-content.css +++ b/src/lib/_imports/objects/o-offset-content.css @@ -8,35 +8,38 @@ Content that should be: Styleguide Objects.OffsetContent */ @import url("../tools/media-queries.css"); +@import url("../tools/x-offset-content.css"); .o-offset-content--left, .o-offset-content--right { - --offset-distance: 12vw; - --buffer: calc( 2 * var(--global-space--grid-gap) ); - - max-width: 85%; + @mixin offset-content; } /* To merely float content on narrow screens */ @media only screen and (--medium-and-above) { .o-offset-content--right { - float: right; - margin-left: var(--buffer); + @mixin offset-content--float-right; + & + & { + @mixin offset-content--terminate-offset-right; + } } - .o-offset-content--right + .o-offset-content--right { clear: right; } .o-offset-content--left { - float: left; - margin-right: var(--buffer); + @mixin offset-content--float-left; + & + & { + @mixin offset-content--terminate-offset-left; + } } - .o-offset-content--left + .o-offset-content--left { clear: left; } - .figure:is( - .o-offset-content--left, - .o-offset-content--right + /* WARNING: Seems specific to one website's use case */ + /* TODO: Determine whether to apply to: +
, only CMS, only Texascale */ + .figure:is( + .o-offset-content--left, + .o-offset-content--right ) .figure-caption { - padding-right: 125px; - } + padding-right: 125px; + } } /* To offset content only on wide screens */ @@ -44,9 +47,9 @@ Styleguide Objects.OffsetContent /* FAQ: M.S. did on texascale.org but that may have been only for that site */ @media only screen and (--medium-and-above)/* and (--max-wide-and-below) */{ .o-offset-content--right { - margin-right: calc( var(--offset-distance) * -1); + @mixin offset-content--offset-right; } .o-offset-content--left { - margin-left: calc( var(--offset-distance) * -1); + @mixin offset-content--offset-left; } } diff --git a/src/lib/_imports/objects/o-offset-content/config.yml b/src/lib/_imports/objects/o-offset-content/config.yml new file mode 100644 index 000000000..cc012f452 --- /dev/null +++ b/src/lib/_imports/objects/o-offset-content/config.yml @@ -0,0 +1,3 @@ +status: ready +context: + shouldSkipPattern: false diff --git a/src/lib/_imports/objects/o-offset-content/o-offset-content.hbs b/src/lib/_imports/objects/o-offset-content/o-offset-content.hbs new file mode 100644 index 000000000..d1ce9128b --- /dev/null +++ b/src/lib/_imports/objects/o-offset-content/o-offset-content.hbs @@ -0,0 +1,13 @@ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.

+ +{{> @figure class="o-offset-content--right" caption="This figure is offset to the right.
On narrow screens, it is
not explicitely offset." }} + +

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+ +

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.

+ +{{> @figure class="o-offset-content--left" caption="This figure is offset to the left.
On narrow screens, it is
not explicitely offset." }} + +

Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet.

+ +

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident.

diff --git a/src/lib/_imports/objects/o-offset-content/readme.md b/src/lib/_imports/objects/o-offset-content/readme.md new file mode 100644 index 000000000..b0049a156 --- /dev/null +++ b/src/lib/_imports/objects/o-offset-content/readme.md @@ -0,0 +1,10 @@ +Content that should be: +1. offset from the flow of text within which it is placed +2. not offset at narrow viewports + +| Class | Description +| - | - | +| `.offset-content--left` | offset content to the left | +| `.offset-content--right` | offset content to the right | + +