The project is divided into three main parts:
- openbridge-webcomponents
- openbridge-webcomponents-vue / openbridge-webcomponents-react
- vue-demo / react-demo
This package contains the implementation of the web components. The components are implemented through the use of the LitElement library.
For each component, there is a corresponding folder in the packages/openbridge-webcomponents/src/components
directory.
The components are implemented in the *.ts
files and the corresponding *.css
files, with a *.stories.ts
file for the storybook.
The css files are post-processed by PostCSS.
There is one global css file for the palettes, variables.css
, which contains the color palettes for the components.
All other css code should be kept inn the *.css
files in the component folders.
The css files uses multiple mixins.
The style
mixin is used to style the component. It takes two arguments:
style
: The style of the component. It can benormal
,flat
,raised
,amplified
,indent
, orselected
.visibleWrapperClass
: [Optional argument] The class of the visible wrapper. Place the mixin in a container for the touch are, and place an element with the chosen class inside the container.
.large-button {
@mixin style style=flat;
}
<div class="large-button"></div>
.small-button {
width: 48px;
height: 48px;
@mixin style style=raised visibleWrapperClass=.visible-wrapper;
}
.visible-wrapper {
width: 10px;
height: 10px;
}
<div class="small-button">
<div class="visible-wrapper">
</div>
</div>
This will create a touch area of 48x48 pixels, and a visible area of 10x10 pixels with the raised style.
There are multiple mixins for styling text:
@mixin font-body-active
@mixin font-body
@mixin font-button
@mixin font-label-active
@mixin font-label
@mixin font-overline
The icons are exported to webcomponents in the packages/openbridge-webcomponents/src/icons
directory.
They are exported from figma by running: yarn run download:icons
.
To create a new component, use the new:component
script:
yarn run new:component
This will create the needed files, using the default template.
Instrument components are based on SVG. Typically they are implemented by copying the SVG code from Figma and pasting it into the component file. Note that these modifications should be done:
- Change the colors of the svg with css variables such as
fill: var(--element-active-color);
- Make stroke non-scaling by adding
vector-effect="non-scaling-stroke"
to the svg tag.
The component file is also more readable if the SVG is splitted up into smaler elements with its own javascript variables. Then later compiled together.