1.16.0 • Published 2 years ago

@magnesium/shape v1.16.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@magnesium/shape

The Magnesium Design shape system help you to create a shape who reflects your design or style.

Installing

npm install @magnesium/shape

Usage

Styles

@use "@magnesium/shape/styles";

This will generate the default theme classes, see CSS Classes section for more.

Configuration

You can define the shape variables before importing any Magnesium components:

@use "@magnesium/shape" with (
    $shapes: (
        large: 24px,
        medium: 12px,
        small: 6px
    )
);

Options

NameDefaultDescription
$shapes()Sets a list of theme shapes.

Customization

CSS custom properties

CSS custom propertyDescription
--mg-shape-radiusGlobal custom property. Override the selected style.
--mg-shape-{style}Override the selected style.

The variable {style} correspond with each key on the $shapes config, see configuration.

CSS classes

CSS ClassDescription
mg-shape--{style}Sets the color to the selected style.

API

Sass mixins

MixinDescription
radius($radius, $no-var)Sets shape radius from $shapes or custom values. Set $no-var to true for generate only value without var().
declaration($property, $style, $important)Sets CSS shape declaration, with optional !important. The value may be a standard CSS value or one of configured theme key.

Radius with shape.radius()

The following Sass...

@use "@magnesium/shape";

.foo {
    @include shape.radius(medium);
}

.bar {
    @include shape.radius(5px);
}

...will produce the following CSS...

.foo {
    border-radius: var(--mg-shape-medium, var(--mg-shape-radius, 12px));
}

.bar {
    border-radius: var(--mg-shape-radius, 5px);
}

Custom properties with shape.declaration()

The following Sass...

@use "@magnesium/shape";

.foo {
    @include shape.declaration(medium); // Will generate a CSS custom property with default shape.
    @include shape.declaration(medium, 16px); // Will generate a CSS custom property with new shape.
}

...will produce the following CSS...

.foo {
    --mg-shape-medium: 12px;
    --mg-shape-medium: 16px;
}

Sass functions

FunctionDescription
exist($radius)Return true if shape radius key exist.
radius($radius)Get CSS shape radius value, without custom property.

Shape with shape.radius()

The following Sass...

@use "@magnesium/shape";

.foo {
    border-radius: shape.radius(medium);
}

...will produce the following CSS...

.foo {
    border-radius: 12px;
}
1.15.0

2 years ago

1.14.0

2 years ago

1.16.0

2 years ago

1.13.2

2 years ago

1.13.1

2 years ago

1.12.2

2 years ago

1.13.0

2 years ago

1.12.1

2 years ago

1.11.2

2 years ago

1.12.0

2 years ago

1.11.1

2 years ago

1.12.0-beta.1

2 years ago

2.0.0-beta.1

2 years ago

1.11.0

2 years ago

1.10.0

2 years ago

1.9.1

2 years ago

1.9.0

2 years ago

1.9.0-beta.1

2 years ago

1.9.4

2 years ago

1.9.3

2 years ago

1.9.2

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.3.2

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.0.0-alpha.8

2 years ago

1.0.0-alpha.7

2 years ago

1.0.0-alpha.6

2 years ago

1.0.0-alpha.5

2 years ago

1.0.0-alpha.4

2 years ago

1.0.0-alpha.3

2 years ago

1.0.0-alpha.2

2 years ago

1.0.0-alpha.1

2 years ago

1.0.0-alpha.0

2 years ago