How to use bpk-react-utils - 10 common examples

To help you get started, we’ve selected a few bpk-react-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Skyscanner / backpack / packages / bpk-docs / src / pages / ColorsPage / ColorsPage.js View on Github external
import STYLES from './colors-page.scss';

import Heading from '../../components/Heading';
import ColorSwatch from '../../components/ColorSwatch';
import DocsPageBuilder from '../../components/DocsPageBuilder';

/* eslint-disable import/no-webpack-loader-syntax */
const coreRgbAse = require('!!file-loader?name=[name].[hash].ase!./../../static/core_rgb.ase');

const coreRgbClr = require('!!file-loader?name=[name].[hash].clr!./../../static/core_rgb.clr');

const extendedRgbAse = require('!!file-loader?name=[name].[hash].ase!./../../static/extended_rgb.ase');

const extendedRgbClr = require('!!file-loader?name=[name].[hash].clr!./../../static/extended_rgb.clr');

const getClassName = cssModules(STYLES);
const containerClassName = getClassName(
  'bpkdocs-colors-page__swatch-container',
);

const components = [
  {
    id: 'primary',
    title: 'Primary',
    blurb: [
      <div>
        
        </div>
github Skyscanner / backpack / packages / bpk-component-icon / src / withDescription.js View on Github external
*   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* @flow strict */

import React, { type AbstractComponent } from 'react';
import { cssModules, wrapDisplayName } from 'bpk-react-utils';

import STYLES from './withDescription.scss';

const getClassName = cssModules(STYLES);

// TODO: Fix flow config. This should receive the component config as a parametized type
export default function withDescription(
  Component: AbstractComponent,
  description: string,
): AbstractComponent {
  const WithDescription = props =&gt; (
    <span>
      
      <span>
        {description}
      </span>
    </span>
  );

  WithDescription.displayName = wrapDisplayName(Component, 'withDescription');
github Skyscanner / backpack / packages / bpk-component-dialog / stories.js View on Github external
*/

/* @flow strict */

import PropTypes from 'prop-types';
import React, { Component, type Node } from 'react';
import BpkText from 'bpk-component-text';
import BpkButton from 'bpk-component-button';
import { storiesOf } from '@storybook/react';
import { cssModules, withDefaultProps } from 'bpk-react-utils';

import STYLES from './stories.scss';

import BpkDialog from './index';

const getClassName = cssModules(STYLES);

const Paragraph = withDefaultProps(BpkText, {
  textStyle: 'base',
  tagName: 'p',
  className: getClassName('bpk-dialog-paragraph'),
});

type Props = {
  children: Node,
  dismissible: boolean,
};

type State = {
  isOpen: boolean,
};
github Skyscanner / backpack / packages / bpk-component-input / src / withOpenEvents.js View on Github external
('ontouchstart' in window ||
        // eslint-disable-next-line no-undef
        (window.DocumentTouch && document instanceof DocumentTouch))
    ),
    onOpen: null,
    // Input props
    className: null,
    onClick: null,
    onFocus: null,
    onBlur: null,
    onTouchEnd: null,
    onKeyDown: null,
    onKeyUp: null,
  };

  WithOpenEvents.displayName = wrapDisplayName(
    InputComponent,
    'withOpenEvents',
  );

  return WithOpenEvents;
};
github Skyscanner / backpack / packages / bpk-component-calendar / src / BpkCalendarGridTransition.js View on Github external
componentWillReceiveProps(nextProps) {
    const hasMonthChanged = !isSameMonth(this.props.month, nextProps.month);

    if (hasMonthChanged) {
      const reverse = isRTL();

      if (differenceInCalendarMonths(nextProps.month, this.props.month) === 1) {
        // Transition to next month
        this.setState({
          transitionValue: reverse
            ? transitionValues.previous
            : transitionValues.next,
          isTransitioning: true,
        });
        return;
      }

      if (
        differenceInCalendarMonths(nextProps.month, this.props.month) === -1
      ) {
        // Transition to previous month
github Skyscanner / backpack / packages / bpk-component-navigation-stack / src / BpkNavigationStack.js View on Github external
const lastIndex = (views || []).length - 1;

    return (
      <div>
        
          {Children.map(views, (view, idx) =&gt; (
            
              </div>
github Skyscanner / backpack / packages / bpk-component-barchart / src / BpkChartAxis.js View on Github external
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import React from 'react';
import PropTypes from 'prop-types';
import { cssModules } from 'bpk-react-utils';
import { spacingXs, lineHeightSm } from 'bpk-tokens/tokens/base.es6';

import { rtlConditionalValue } from './RTLtransforms';
import { ORIENTATION_X, ORIENTATION_Y } from './orientation';
import { identity, center, remToPx } from './utils';
import STYLES from './BpkChartAxis.scss';

const getClassName = cssModules(STYLES);

const spacing = remToPx(spacingXs);
const lineHeight = remToPx(lineHeightSm);

const getAxisConfig = ({ orientation, margin, height, width, scale }) => {
  const position = (scale.bandwidth ? center : identity)(scale.copy());

  if (orientation === ORIENTATION_X) {
    return {
      containerProps: {
        textAnchor: 'middle',
        transform: `translate(0, ${height - margin.bottom - margin.top})`,
      },
      textProps: {
        y: lineHeight,
        x: 0,
github Skyscanner / backpack / packages / bpk-component-router-link / src / BpkRouterLink.js View on Github external
*
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import React from 'react';
import PropTypes from 'prop-types';
import { NavLink } from 'react-router-dom';
import { cssModules } from 'bpk-react-utils';

import STYLES from './BpkRouterLink.scss';

const getClassName = cssModules(STYLES);

const BpkRouterLink = props =&gt; {
  const classNames = [getClassName('bpk-router-link')];
  const { children, to, className, ...rest } = props;

  if (className) {
    classNames.push(className);
  }

  return (
github Skyscanner / backpack / packages / bpk-component-link / src / BpkButtonLink.js View on Github external
*
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import PropTypes from 'prop-types';
import React from 'react';
import { cssModules } from 'bpk-react-utils';

import themeAttributes from './themeAttributes';
import STYLES from './BpkLink.scss';

const getClassName = cssModules(STYLES);

const BpkButtonLink = props =&gt; {
  const { children, className, onClick, white, alternate, ...rest } = props;
  const classNames = [getClassName('bpk-link')];

  if (white || alternate) {
    classNames.push(getClassName('bpk-link--alternate'));
  }
  if (className) {
    classNames.push(className);
  }

  return (
github Skyscanner / backpack / packages / bpk-docs / src / pages / StatefulnessPage / StatefulnessPage.js View on Github external
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import React from 'react';
import BpkLink from 'bpk-component-link';
import { BpkList, BpkListItem } from 'bpk-component-list';
import { cssModules } from 'bpk-react-utils';
import DocsPageBuilder from './../../components/DocsPageBuilder';
import Heading from './../../components/Heading';
import Paragraph from './../../components/Paragraph';

import STYLES from './statefulness-page.scss';

const getClassName = cssModules(STYLES);
const ScottHurffLink = 'http://scotthurff.com/dppl/';

const StatefulnessPage = () =&gt; 
    Statefulness refers to a component's ability to change its appearance depending on the context
    or interaction behaviour.
    ,
    The 5 view states,
    
      Every screen users interact with has different states. Leaning on the research and
      work by Scott Hurff we can assume that in most cases
      there are five.
    ,

bpk-react-utils

Utilities for Backpack's React components.

Apache-2.0
Latest version published 2 years ago

Package Health Score

73 / 100
Full package analysis

Similar packages