0.0.1 • Published 3 years ago

alanzoutest v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Juno

Ringcentral React Component library

base on MATERIAL-UI

Install

package.json

npm i @ringcentral/juno styled-components
// or
yarn add @ringcentral/juno styled-components

Basic Using

All components we using need contain in the RcThemeProvider.

import {
  RcAvatar,
  RcTooltip,
  RcButton,
  RcIcon,
  RcLink,
  RcCircularProgress,
  RcThemeProvider,
} from '@ringcentral/juno';
<RcThemeProvider>
  <RcAvatar color="lake">SH</RcAvatar>
  <RcButton>Button</RcButton>
  <RcLink>LINK</RcLink>
  <RcCircularProgress />
  <RcCircularProgress size="{30}" color="secondary" />
</RcThemeProvider>

Custom Theme

You can custom theme by theme props with RcThemeInput object like below, all of option you can see type RcThemeInput;

const defaultTheme: RcThemeInput = {
  palette: {
    primary: {
      main: '#0684bd',
    },
    ...
  },
};

const App = (props) => {
  return (
    <RcThemeProvider theme={theme}>
      <RcCircularProgress />
    </RcThemeProvider>
  );
};

Icons

Use build in component

We can use any component with RcIcon prop symbol, pass component into symbol that will render svg icon with our RcIcon style.

import { RcIcon } from '@ringcentral/juno';
// also can use default import
// import Phone from '@ringcentral/juno/icon/Phone';

import { Phone } from '@ringcentral/juno/icon';

const App = (props) => {
  return (
    <RcThemeProvider>
      <RcIcon symbol={Phone} />
    </RcThemeProvider>
  );
};

Use Svg

using @svgr/webpack to load svg as component.

you can import from '@ringcentral/juno/icons/*.svg, using like below.

import phoneSvg from '@ringcentral/juno/icons/icon-phone.svg';

const App = (props) => {
  return (
    <RcThemeProvider>
      <RcIcon symbol={phoneSvg} />
    </RcThemeProvider>
  );
};

Use Token

Styled-component

You can use Juno token from foundation like below

activeOpacity

.class {
    ${activeOpacity()}
}

opacity

.class {
    opacity: ${opacity('3')}
}

palette

.class {
    color: ${palette2('text', 'dark')}
}

radius

.class {
    border-radius: ${radius('circle')}
}

shadows

.class {
    border-radius: ${shadows(2)}
}

shape

  .class {
    border-top: ${shape('border4')};
  }

spacing

.class {
  margin: ${spacing(2)};  // margin: 8
  padding: ${spacing(1, 2, 3, 4)}; // margin: 4 8 12 16
}

typography

.class {
  ${typography('body1')};
}

zIndex

.class {
  z-index: ${zIndex('dialog')}; // 6000
}

Scss

You can also use token with scss file

@import '@ringcentral/juno/scss/theming';

Create global color style

Create all color class

@include generate-rc-static-style();
/** 
  rc-bg-xxx, ex: rc-bg-primary-main => background-color: #4475fd
  rc-text-xxx, ex: rc-text-primary-main => color: #4475fd
  rc-border-xxx, ex: rc-border-primary-main => border-color: #4475fd
*/

buildIn mixin and function

nametypedescriptionExampleresult
rc-opacity@functionget opacity from theme tokenopacity: rc-opacity('1')opacity: 0.1
rc-breakpoints@functionget breakpoint from theme token@media screen and (max-width: rc-breakpoints('md')) { }@media screen and (max-width: 640px) { }
rc-shape@functionget shape from theme tokenborder: rc-shape('border3')border: 1px solid rgba(0, 0, 0, 0.36)
rc-typography@mixinappend typography style from theme token@include rc-typography('body1')font-size: 3.5rem; font-weight: 400; line-height: 72px
rc-zIndex@mixinappend zIndex style from theme token@include rc-zIndex('banner')z-index: 9500
rc-radius@mixinappend border-radius style from theme token@include rc-radius('circle')border-radius: 50%
rc-spacing@functionappend spacing style from theme tokenmargin: rc-spacing(1, 2, 3, 4)margin: 4 8 12 16
rc-palette@functionget palette from theme tokencolor: rc-palette(element, primary)color: #4475FD
with-rc-theme@mixinlet user can use this to get both theme colornpm.iolight .paper { color: #4475FD } dark .paper { color: #729AFF }
with-rc-theme-type@mixinlet user can use this to get target theme colornpm.iodark .paper { color: #729AFF }
custom-rc-palette@functionSet custom palette colornpm.iothat will change the whole project default light and dark theme

Deprecated Warning

If you use some deprecated methods, we will show warning when you use in development mode, if you don't want see those warning, you can turn off that by set

import { configure } from '@ringcentral/juno';

configure({
  warning: false,
});

or just use window to set

window.__JUNO__.WARNING_IGNORE = true;

BUT, Don't recommended you close it, we should avoid use any deprecated props or methods.

moment

if you use RcDatePicker or AudioPlayer, we calculate time depend on moment.js you should install moment

npm i moment
// or
yarn add moment