8.3.1 • Published 3 days ago

@admiral-ds/react-ui v8.3.1

Weekly downloads
-
License
See license in ./...
Repository
github
Last release
3 days ago

@admiral-ds/react-ui

Библиотека компонентов React, основанная на дизайн системе Admiral 2.1

Содержимое

Установка

@admiral-ds/react-ui требует зависимостей :

  1. styled-components > 5.1.0
  2. react > 16.0.0
  3. react-dom > 16.0.0

    Можно воспользоваться готовым темплейтом с настроенной библиотекой https://github.com/AdmiralDS/web-app-vite-admiral или создать проект снуля и установить библиотеку:

$ npm create vite@latest my-web-app -- --template react-ts
$ cd my-web-app
$ npm install
$ npm i @admiral-ds/react-ui
$ npm run dev

Подключение

Для правильной работы @admiral-ds/react-ui требуется использовать <ThemeProvider>, <FontsVTBGroup /> и <DropdownProvider>, их рекомендуется подключать в корне проекта:

main.tsx

import React from 'react';
import ReactDOM from 'react-dom/client';
import { ThemeProvider } from 'styled-components';
import { LIGHT_THEME, FontsVTBGroup, DropdownProvider } from '@admiral-ds/react-ui';
import App from './App';
import './index.css';

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <ThemeProvider theme={LIGHT_THEME}>
      <DropdownProvider>
        <FontsVTBGroup />
        <App />
      </DropdownProvider>
    </ThemeProvider>
  </React.StrictMode>,
);

App.tsx

import { useState } from 'react';
import styled from 'styled-components';
import './App.css';

// Импорт иконки как URL ресурс
import reactLogo from './assets/react.svg';
import { T, Link } from '@admiral-ds/react-ui';

const Divider = styled.div`
  width: 10px;
  height: 12px;
`;

function App() {
  const [count, setCount] = useState(0);

  return (
    <>
      <div>
        <a href="https://vitejs.dev" target="_blank">
          {/* импорт иконки через директорию assets. Доступ к этой директории есть и у index.html */}
          <img src="/vite.svg" className="logo" alt="Vite logo" />
        </a>
        <a href="https://react.dev" target="_blank">
          <img src={reactLogo} className="logo react" alt="React logo" />
        </a>
      </div>
      <h1>Vite + React</h1>
      <div className="card">
        <button className="button" onClick={() => setCount((count) => count + 1)}>
          count is {count}
        </button>
        <T font="Subtitle/Subtitle 1" as="p">
          Edit <code>src/App.tsx</code> and save to test HMR
        </T>
      </div>
      <p className="read-the-docs">Click on the Vite and React logos to learn more</p>
      <Link appearance="primary" href="https://admiralds.github.io/react-ui" target="_blank" rel="noopener noreferrer">
        Admiral Storybook
        <Divider />
      </Link>
    </>
  );
}

export default App;

Если ваш проект НЕ использует create-react-app , то для правильной работы webpack вам потребуется настройка file-loader, и SVGR.

$ npm i -D @svgr/webpack

webpack.config.js

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const AppConfig = require('./src/app.config');

module.exports = {
  entry: './src/index.tsx',
  output: {
    path: path.resolve(__dirname, 'public'),
    filename: 'main.bundle.js',
    publicPath: AppConfig.webPackPublicPath,
  },
  plugins: [
    new HtmlWebpackPlugin({
      favicon: 'src/favicon.ico',
      template: 'src/index.html',
    }),
  ],
  module: {
    rules: [
      {
        test: /\.svg$/i,
        issuer: /\.[jt]sx?$/,
        use: ['@svgr/webpack'],
      },
      {
        test: /\.(gif|svg|jpg|png|otf|ttf)$/,
        use: 'file-loader',
      },
      {
        test: /\.(js|ts|tsx)$/,
        use: 'ts-loader',
        exclude: /node_modules/,
      },
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader'],
      },
    ],
  },
  resolve: {
    extensions: ['.tsx', '.ts', '.js'],
  },
  devServer: {
    hot: true,
  },
};
8.3.1

3 days ago

8.3.0

6 days ago

8.2.0

12 days ago

8.1.1

23 days ago

8.1.0

24 days ago

8.0.3

29 days ago

8.0.2

1 month ago

8.0.1

1 month ago

8.0.0

1 month ago

7.15.0

2 months ago

7.14.2

2 months ago

7.14.0

2 months ago

7.14.1

2 months ago

7.13.0

2 months ago

7.12.2

2 months ago

7.12.1

3 months ago

7.12.0

3 months ago

7.11.1

3 months ago

7.11.0

3 months ago

7.10.0

3 months ago

7.9.2

3 months ago

7.9.1

4 months ago

7.9.0

4 months ago

7.8.4

4 months ago

7.8.3

4 months ago

7.8.2

5 months ago

7.8.1

5 months ago

7.8.0

5 months ago

7.7.0

5 months ago

7.6.1

5 months ago

7.6.0

5 months ago

7.5.1

5 months ago

7.5.0

6 months ago

7.4.1

6 months ago

7.4.0

6 months ago

7.3.0

7 months ago

5.3.0

10 months ago

6.1.0

8 months ago

6.3.0

8 months ago

6.1.1

8 months ago

7.1.0

7 months ago

5.4.0

10 months ago

6.0.0

9 months ago

6.2.0

8 months ago

7.0.0

7 months ago

7.2.0

7 months ago

5.1.0

11 months ago

5.2.0

11 months ago

5.0.1

11 months ago

5.0.0

11 months ago

4.17.0

11 months ago

4.14.1

12 months ago

4.16.0

12 months ago

4.16.1

12 months ago

4.12.0

1 year ago

4.14.0

12 months ago

4.15.0

12 months ago

4.15.1

12 months ago

4.11.0

1 year ago

4.11.1

1 year ago

4.13.0

1 year ago

4.11.2

1 year ago

4.9.2

1 year ago

4.9.1

1 year ago

4.10.0

1 year ago

4.4.1

1 year ago

4.4.0

1 year ago

4.6.0

1 year ago

4.4.2

1 year ago

4.2.0

1 year ago

4.8.1

1 year ago

4.8.0

1 year ago

4.5.0

1 year ago

4.7.0

1 year ago

4.5.2

1 year ago

4.5.1

1 year ago

4.3.0

1 year ago

3.10.1

1 year ago

3.10.0

1 year ago

4.1.0

1 year ago

4.0.0

1 year ago

3.8.3

1 year ago

3.8.2

1 year ago

3.9.0

1 year ago

3.8.1

1 year ago

3.4.0

1 year ago

3.3.0

1 year ago

3.2.0

2 years ago

3.1.0

2 years ago

3.0.1

2 years ago

3.8.0

1 year ago

3.7.0

1 year ago

3.6.0

1 year ago

3.5.0

1 year ago

2.5.0

2 years ago

2.4.0

2 years ago

2.3.0

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.2.2

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.10.0

2 years ago

1.2.0

2 years ago

1.9.0

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.5.2

2 years ago

1.6.0

2 years ago

1.5.1

2 years ago

1.4.2

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.9.1

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago