Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .storybook/assets/example-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Example layout for the Optics design system" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@rolemodel/optics@2.3.1/dist/css/optics.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@rolemodel/optics@2.4.0/dist/css/optics.min.css" />
<!-- <link rel="stylesheet" href="../src/optics.css" /> Enable this during development to see local changes -->
<script type="module" src="https://esm.sh/invokers-polyfill"></script>
<title>Optics Example Layout</title>
Expand Down
2 changes: 1 addition & 1 deletion .storybook/assets/login-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Example layout for the Optics design system" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@rolemodel/optics@2.3.1/dist/css/optics.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@rolemodel/optics@2.4.0/dist/css/optics.min.css" />
<!-- <link rel="stylesheet" href="../src/optics.css" /> Enable this during development to see local changes -->
<title>Optics Login Layout</title>
<style>
Expand Down
2 changes: 1 addition & 1 deletion .storybook/assets/spinner-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Example layout for the Optics design system" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@rolemodel/optics@2.3.1/dist/css/optics.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@rolemodel/optics@2.4.0/dist/css/optics.min.css" />
<!-- <link rel="stylesheet" href="../src/optics.css" /> Enable this during development to see local changes -->
<title>Optics Spinner Layout</title>
<style>
Expand Down
8 changes: 3 additions & 5 deletions .storybook/preview.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,17 @@
}
}

/* Set playground / preview background */
.sbdocs-preview .docs-story {
background-color: var(--op-color-background);
color: var(--op-color-on-background);
}

/* Fix tooltip demo issue */
.sbdocs .sb-button-fix button {
block-size: 0;
}

/* Allow the "Show Code" button to appear above the footer in examples. */
.docs-story div:last-child:has(.docblock-code-toggle) {
z-index: 1;
}

/* Transition Demos */
.transition-demo {
display: inline-block;
Expand Down Expand Up @@ -161,6 +158,7 @@
font-weight: initial;
letter-spacing: initial;
line-height: 19px;
user-select: initial;
}
}

Expand Down
12 changes: 11 additions & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ const preview = {
['Base Reset', 'File Organization', 'Selective Imports', 'Tokens', 'Themes', 'Scale Overriding', 'Addons'],
'Tokens',
'Utilities',
['Introduction'],
[
'Introduction',
'Container',
'Item Width',
'Margin',
'Text Alignment',
'Visibility',
'Flex',
'Gap',
'Advanced',
],
'Components',
'Recipes',
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rolemodel/optics",
"version": "2.3.1",
"version": "2.4.0",
"packageManager": "yarn@4.8.1",
"description": "Optics is a css package that provides base styles and components that can be integrated and customized in a variety of projects.",
"main": "dist/css/optics.css",
Expand Down
6 changes: 5 additions & 1 deletion src/components/text_pair.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

display: flex;
flex-direction: column;
gap: var(--op-space-x-small);

/* zero specificity. Lets utilities override */
:where(&) {
gap: var(--op-space-x-small);
}

&.text-pair--inline {
flex-direction: row;
Expand Down
167 changes: 157 additions & 10 deletions src/core/utilities.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
}

/* Gap Properties */
.gap-none {
gap: 0;

--op-gap: 0;
}

.gap-xxs {
gap: var(--op-space-2x-small);

Expand Down Expand Up @@ -424,31 +430,172 @@
.op-stack {
display: flex;
flex-direction: column;
}
margin-block: 0;
margin-inline: 0;

:where(.op-stack) {
gap: var(--op-space-medium);
/* zero specificity. Lets utilities override */
:where(&) {
gap: var(--op-space-medium);
}
}

/* Equivalent to .flex.flex-wrap.items-center.gap-md */
.op-cluster {
display: flex;
flex-wrap: wrap;
}
margin-block: 0;
margin-inline: 0;

:where(.op-cluster) {
align-items: center;
gap: var(--op-space-medium);
/* zero specificity. Lets utilities override */
:where(&) {
align-items: center;
gap: var(--op-space-medium);
}
}

/* Equivalent to .flex.flex-wrap.items-center.justify-between.gap-md */
.op-split {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin-block: 0;
margin-inline: 0;

/* zero specificity. Lets utilities override */
:where(&) {
align-items: center;
gap: var(--op-space-medium);
}
}

:where(.op-split) {
align-items: center;
gap: var(--op-space-medium);
/*
side by side layout with a small area and a large area
similar to .flex with a .flex-grow-1 within it, but with a more semantic name and wrap handling.

|[] [ ]|
|[ ] []| with end
*/
.op-flank {
display: flex;
margin-block: 0;
margin-inline: 0;

/* zero specificity. Lets utilities override */
:where(&) {
flex-wrap: wrap;
align-items: center;
gap: var(--op-space-medium);
}

/* Small area */
&:not(.op-flank--end) > :first-child,
&.op-flank--end > :last-child {
flex-basis: auto;
flex-grow: 1;
}

/* Large area */
&:not(.op-flank--end) > :last-child,
&.op-flank--end > :first-child {
flex-basis: 0;
flex-grow: 999;
}
}

/* Grid Layout */
.op-grid {
--_op-grid-min-column-size: var(--op-space-4x-large);
--_op-grid-max-column-size: 0px;

display: grid;
grid-template-columns: repeat(
auto-fit,
minmax(max(var(--_op-grid-min-column-size), var(--_op-grid-max-column-size)), 1fr)
);
margin-block: 0;
margin-inline: 0;

/* zero specificity. Lets utilities override */
:where(&) {
gap: var(--op-space-medium);
}

&.op-grid--2-column {
--_op-grid-max-column-size: calc(100% / 3);
}

&.op-grid--3-column {
--_op-grid-max-column-size: calc(100% / 4);
}

&.op-grid--4-column {
--_op-grid-max-column-size: calc(100% / 5);
}

&.op-grid--5-column {
--_op-grid-max-column-size: calc(100% / 6);
}

&.op-grid--6-column {
--_op-grid-max-column-size: calc(100% / 7);
}
}

/* Frame */
@property --_op-frame-inline-size {
inherits: true;
initial-value: 100%;
syntax: '<length> | <percentage>';
}

.op-frame {
display: flex;
overflow: hidden;
border-radius: inherit;
aspect-ratio: 1 / 1;
margin-block: 0;
margin-inline: 0;
max-inline-size: var(--_op-frame-inline-size);

:where(&) {
align-items: center;
justify-content: center;
}

> img,
> video {
block-size: 100%;
inline-size: 100%;
object-fit: cover;
}

/* aspect ratio */

&.op-frame--square {
aspect-ratio: 1 / 1;
}

&.op-frame--landscape {
aspect-ratio: 16 / 9;
}

&.op-frame--portrait {
aspect-ratio: 9 / 16;
}

&.op-frame--4-3 {
aspect-ratio: 4 / 3;
}

&.op-frame--3-4 {
aspect-ratio: 3 / 4;
}

&.op-frame--3-2 {
aspect-ratio: 3 / 2;
}

&.op-frame--2-3 {
aspect-ratio: 2 / 3;
}
}
5 changes: 4 additions & 1 deletion src/stories/Components/TextPair/TextPair.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ export const createTextPair = ({
titleSize = '',
subtitleText = 'This is the Subtitle',
subtitleSize = '',
gap = '',
}) => {
const element = document.createElement('div')

element.className = ['text-pair', inline ? 'text-pair--inline' : ''].filter(Boolean).join(' ')
element.className = ['text-pair', inline ? 'text-pair--inline' : '', gap ? `gap-${gap}` : '']
.filter(Boolean)
.join(' ')

const title = document.createElement('span')
title.className = ['text-pair__title', titleSize === '' ? '' : `text-pair__title--${titleSize}`]
Expand Down
4 changes: 4 additions & 0 deletions src/stories/Components/TextPair/TextPair.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export default {
control: { type: 'select' },
options: ['small', 'medium', 'large'],
},
gap: {
control: { type: 'select' },
options: ['none', 'xxs', 'xs', 'sm', 'md', 'lg', 'xl'],
},
},
}

Expand Down
Loading
Loading