@scania/tegel
TypeScript icon, indicating that this package has built-in type declarations

1.28.1 • Public • Published

Github release Storybook Status: Beta node-current

@scania/tegel

Official website: https://tegel.scania.com/

Storybook: https://tds-storybook.tegel.scania.com/

The design system supports the design and development of digital solutions at Scania. The purpose is to secure a coherent, premium brand and user experience across all of Scania's digital touchpoints.

Status

This package is currently considered a beta. Version 1.0.0 and later are released, and we see no braking changes coming in near future.

Installation

React

with Typescript

  1. Run npm install @scania/tegel
  2. src folder create a file called register-webcomponents.ts
  3. Paste the following into that file:
import { defineCustomElements, JSX as LocalJSX } from '@scania/tegel/loader';
import { DetailedHTMLProps, HTMLAttributes } from 'react';

type StencilProps<T> = {
  [P in keyof T]?: Omit<T[P], 'ref'> | HTMLAttributes<T>;
};

type ReactProps<T> = {
  [P in keyof T]?: DetailedHTMLProps<HTMLAttributes<T[P]>, T[P]>;
};

type StencilToReact<T = LocalJSX.IntrinsicElements, U = HTMLElementTagNameMap> = StencilProps<T> &
  ReactProps<U>;

declare global {
  export namespace JSX {
    interface IntrinsicElements extends StencilToReact {}
  }
}

defineCustomElements(window);
  1. In your index.tsx import register-webcomponents.ts
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import './register-webcomponents';

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
);

reportWebVitals();
  1. In your global css file (usually App.css) import the tegel stylesheet.
@import url('@scania/tegel/dist/tegel/tegel.css');

with Javascript

  1. Run npm install @scania/tegel
  2. In your index.jsx define the custom components:
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { defineCustomElements } from '@scania/tegel/loader';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
);

reportWebVitals();
defineCustomElements();
  1. In your global css file (usually App.css) import the tegel stylesheet.
@import url('@scania/tegel/dist/tegel/tegel.css');

Angular

  1. Run npm install @scania/tegel
  2. In your main.ts import and call the function defineCustomElements():
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { defineCustomElements } from '@scania/tegel/loader';
import { AppModule } from './app/app.module';

platformBrowserDynamic()
  .bootstrapModule(AppModule)
  .catch((err) => console.error(err));

defineCustomElements(window);
  1. In your app.module.ts import CUSTOM_ELEMENTS_SCHEMA:
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule],
  providers: [],
  bootstrap: [AppComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
  1. In your global css file (styles.css) import the tegel stylesheet.
@import url('@scania/tegel/dist/tegel/tegel.css');

HTML

  1. Run npm init to generate a package.json
  2. Run npm install @scania/tegel
  3. Import the package and its style in your <head>:
<script type="module">
  import { defineCustomElements } from './node_modules/@scania/tegel/loader/index.es2017.js';
  defineCustomElements();
</script>
<link rel="stylesheet" href="./node_modules/@scania/tegel/dist/tegel/tegel.css" />

See all available components in the Tegel Design System.

Browser support

See the browser support section on the Tegel website.

Community

Get in touch with the team and the community:

License

All CSS, HTML and JS code are available under the MIT license. The Scania brand identity, logos and photographs found in this repository are copyrighted Scania CV AB and are not available on an open source basis or to be used as examples or in any other way, if not specifically ordered by Scania CV AB.

Package Sidebar

Install

npm i @scania/tegel

Weekly Downloads

2,129

Version

1.28.1

License

MIT

Unpacked Size

6.61 MB

Total Files

825

Last publish

Collaborators

  • the_johnny.me
  • tegel-scania
  • nathalielindqvist
  • emelielitwin
  • bickson
  • mistermalm
  • timrom
  • ckrook