-
Notifications
You must be signed in to change notification settings - Fork 2
Improve visual enum system #58
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
Open
thibaultzanini
wants to merge
4
commits into
main
Choose a base branch
from
feat/visual-enums
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,33 @@ | ||
| const { Enum } = require("../enum"); | ||
| const Enum = require("../enum").Enum; | ||
|
|
||
| const orientations = ["horizontal", "vertical"]; | ||
| const classNames = orientations.map((orientation) => { | ||
| return `mod--orientation-${orientation}`; | ||
| }); | ||
|
|
||
| /** | ||
| * Visual orientation types for components. | ||
| * @typedef {"horizontal"|"vertical"} VisualOrientation | ||
| */ | ||
|
|
||
| /** | ||
| * VisualOrientation enum with available orientation values. | ||
| * @type {Object.<string, VisualOrientation>} | ||
| * @property {string} horizontal - Horizontal layout orientation | ||
| * @property {string} vertical - Vertical layout orientation | ||
| */ | ||
| exports.VisualOrientation = new Enum().initWithMembersAndValues( | ||
| ["horizontal", "vertical"], | ||
| ["mod--horizontal", "mod--vertical"] | ||
| orientations, | ||
| orientations | ||
| ); | ||
|
|
||
| /** | ||
| * CSS class names corresponding to visual orientations. | ||
| * @type {Object.<string, string>} | ||
| * @property {string} horizontal - CSS class "mod--orientation-horizontal" | ||
| * @property {string} vertical - CSS class "mod--orientation-vertical" | ||
| */ | ||
| exports.VisualOrientationClassNames = new Enum().initWithMembersAndValues( | ||
| orientations, | ||
| classNames | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,31 @@ | ||
| const { Enum } = require("../enum"); | ||
| const Enum = require("../enum").Enum; | ||
|
|
||
| const positions = ["start", "end"]; | ||
| const classNames = positions.map((position) => `mod--position-${position}`); | ||
|
|
||
| /** | ||
| * Visual position types for components. | ||
| * @typedef {"start"|"end"} VisualPosition | ||
| */ | ||
|
|
||
| /** | ||
| * VisualPosition enum with available position values. | ||
| * @type {Object.<string, VisualPosition>} | ||
| * @property {string} start - Position at the beginning/start | ||
| * @property {string} end - Position at the end | ||
| */ | ||
| exports.VisualPosition = new Enum().initWithMembersAndValues( | ||
| ["start", "end"], | ||
| ["mod--start", "mod--end"] | ||
| positions, | ||
| positions | ||
| ); | ||
|
|
||
| /** | ||
| * CSS class names corresponding to visual positions. | ||
| * @type {Object.<string, string>} | ||
| * @property {string} start - CSS class "mod--position-start" | ||
| * @property {string} end - CSS class "mod--position-end" | ||
| */ | ||
| exports.VisualPositionClassNames = new Enum().initWithMembersAndValues( | ||
| positions, | ||
| classNames | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| const Enum = require("../enum").Enum; | ||
|
|
||
| const shapes = ["rectangle", "rounded", "pill"]; | ||
| const classNames = shapes.map((shape) => `mod--shape-${shape}`); | ||
|
|
||
| /** | ||
| * Visual shape types for components. | ||
| * @typedef {"rectangle"|"rounded"|"pill"} VisualShape | ||
| */ | ||
|
|
||
| /** | ||
| * VisualShape enum with available shape values. | ||
| * @type {Object.<string, VisualShape>} | ||
| * @property {string} rectangle - Rectangle shape with sharp corners | ||
| * @property {string} rounded - Shape with rounded corners | ||
| * @property {string} pill - Pill shape with fully rounded ends | ||
| */ | ||
| exports.VisualShape = new Enum().initWithMembersAndValues( | ||
| shapes, | ||
| shapes | ||
| ); | ||
|
|
||
| /** | ||
| * CSS class names corresponding to visual shapes. | ||
| * @type {Object.<string, string>} | ||
| * @property {string} rectangle - CSS class "mod--shape-rectangle" | ||
| * @property {string} rounded - CSS class "mod--shape-rounded" | ||
| * @property {string} pill - CSS class "mod--shape-pill" | ||
| */ | ||
| exports.VisualShapeClassNames = new Enum().initWithMembersAndValues( | ||
| shapes, | ||
| classNames | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| const Enum = require("../enum").Enum; | ||
|
|
||
| const sizes = ["small", "medium", "large"]; | ||
| const classNames = sizes.map((size) => `mod--size-${size}`); | ||
|
|
||
| /** | ||
| * Visual size types for components. | ||
| * @typedef {"small"|"medium"|"large"} VisualSize | ||
| */ | ||
|
|
||
| /** | ||
| * VisualSize enum with available size values. | ||
| * @type {Object.<string, VisualSize>} | ||
| * @property {string} small - Small size variant | ||
| * @property {string} medium - Medium size variant | ||
| * @property {string} large - Large size variant | ||
| */ | ||
| exports.VisualSize = new Enum().initWithMembersAndValues(sizes, sizes); | ||
|
|
||
| /** | ||
| * CSS class names corresponding to visual sizes. | ||
| * @type {Object.<string, string>} | ||
| * @property {string} small - CSS class "mod--size-small" | ||
| * @property {string} medium - CSS class "mod--size-medium" | ||
| * @property {string} large - CSS class "mod--size-large" | ||
| */ | ||
| exports.VisualSizeClassNames = new Enum().initWithMembersAndValues( | ||
| sizes, | ||
| classNames | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| const Enum = require("../enum").Enum; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't thing variant as proposed here makes sense either, |
||
|
|
||
| const variants = ["outlined", "plain"]; | ||
| const classNames = variants.map((variant) => `mod--variant-${variant}`); | ||
|
|
||
| /** | ||
| * Visual variant types for components. | ||
| * @typedef {"outlined"|"plain"} VisualVariant | ||
| */ | ||
|
|
||
| /** | ||
| * VisualVariant enum with available visual variants. | ||
| * @type {Object.<string, VisualVariant>} | ||
| * @property {string} outlined - Component with outline styling | ||
| * @property {string} plain - Component with minimal/default styling | ||
| */ | ||
| exports.VisualVariant = new Enum().initWithMembersAndValues(variants, variants); | ||
|
|
||
| /** | ||
| * CSS class names corresponding to visual variants. | ||
| * @type {Object.<string, string>} | ||
| * @property {string} outlined - CSS class "mod--variant-outlined" | ||
| * @property {string} plain - CSS class "mod--variant-plain" | ||
| */ | ||
| exports.VisualVariantClassNames = new Enum().initWithMembersAndValues( | ||
| variants, | ||
| classNames | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think Shape makes sense. "Roundness" is the most plain language I can think of, "curvature" could work too, though it's more used for line, paths, and in typography.
I think roundness should be one of those "high level" lever in a Visual Style and be a value from 0 to 10 or 100? 0: sharp angles, Max, half circle.
There's 2d surface roundness, also known as corner radius in a more technical way, but there's also 3d roundness:
3D adds depth, so roundness affects both edges and surfaces.
A flat rounded button would have a rounded surface bo a sharp 3D roundness. But an Aqua button look / pill would have both 2D and 3D roundness