Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Skyscanner/backpack into CardListCo…
Browse files Browse the repository at this point in the history
…mponentWeb
  • Loading branch information
YJ Lee committed Aug 6, 2024
2 parents a35d91e + 7d9573d commit 5006ce4
Show file tree
Hide file tree
Showing 65 changed files with 4,079 additions and 1,695 deletions.
17 changes: 17 additions & 0 deletions examples/bpk-component-accordion/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,22 @@ const SingleItemExampleWithoutDivider = () => (
</SingleItemAccordion>
);

const SingleItemExampleWithoutDividerOnDark = () => (
<div style={{ backgroundColor: surfaceContrastDay }}>
<SingleItemAccordion divider={false} onDark>
<BpkAccordionItem id="stops" title="Stops" initiallyExpanded>
<StopsContent />
</BpkAccordionItem>
<BpkAccordionItem id="airlines" title="Airlines">
<AirlinesContent />
</BpkAccordionItem>
<BpkAccordionItem id="airports" title="Airports">
<AirportsContent />
</BpkAccordionItem>
</SingleItemAccordion>
</div>
);

export {
SingleItemExample,
SingleItemExampleInitiallyExpandedExample,
Expand All @@ -403,4 +419,5 @@ export {
WithSeoContentExample,
WithSeoContentOnDarkExample,
SingleItemExampleWithoutDivider,
SingleItemExampleWithoutDividerOnDark,
};
13 changes: 8 additions & 5 deletions examples/bpk-component-accordion/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* limitations under the License.
*/



import BpkAccordion from '../../packages/bpk-component-accordion/src/BpkAccordion';
import BpkAccordionItem from '../../packages/bpk-component-accordion/src/BpkAccordionItem';

Expand All @@ -34,8 +32,12 @@ import {
WithSeoContentExample,
WithSeoContentOnDarkExample,
SingleItemExampleWithoutDivider,
SingleItemExampleWithoutDividerOnDark,
} from './examples';
import { WithSingleItemAccordionStateMock, WithAccordionItemStateMock } from './stories-utils';
import {
WithSingleItemAccordionStateMock,
WithAccordionItemStateMock,
} from './stories-utils';

export default {
title: 'bpk-component-accordion',
Expand Down Expand Up @@ -70,11 +72,12 @@ export const WithContent = WithSeoContentExample;
export const WithSeoContentOnDark = WithSeoContentOnDarkExample;

export const WithoutDivider = SingleItemExampleWithoutDivider;
export const WithoutDividerOnDark = SingleItemExampleWithoutDividerOnDark;

export const VisualTest = SingleItemExample;
export const VisualTestOnDark = WithDarkBackgroundExample;

export const VisualTestWithZoom = VisualTest.bind({});
VisualTestWithZoom.args = {
zoomEnabled: true
};
zoomEnabled: true,
};
8 changes: 8 additions & 0 deletions examples/bpk-component-button/examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ const FullWidthExample = (props: any) => (
</BpkButtonV2>
);

const SubmitButtonExample = (props: any) => (
<BpkButtonV2 submit {...props}>
Submit Button
</BpkButtonV2>
);

const MixedExample = () => (
<>
<PrimaryExample />
Expand All @@ -188,6 +194,7 @@ const MixedExample = () => (
<LinkOnDarkExample />
<FeaturedExample />
<FullWidthExample />
<SubmitButtonExample />
</>
);

Expand Down Expand Up @@ -218,4 +225,5 @@ export {
MixedExample,
AnchorTagsExample,
FullWidthExample,
SubmitButtonExample,
};
3 changes: 2 additions & 1 deletion examples/bpk-component-button/stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
MixedExample,
AnchorTagsExample,
FullWidthExample,
SubmitButtonExample,
} from './examples';
import { MixedExample as MixedExampleV1 } from './examplesv1';

Expand Down Expand Up @@ -75,5 +76,5 @@ export const VisualTestV1WithZoom = {
zoomEnabled: true,
},
};

export const SubmitButton = () => <SubmitButtonExample />;
export const FullWidth = () => <FullWidthExample />;
186 changes: 186 additions & 0 deletions examples/bpk-component-dialog/examples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/*
* Backpack - Skyscanner's Design System
*
* Copyright 2016 Skyscanner Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 PropTypes from 'prop-types';
import { Component } from 'react';
import type { Node } from 'react';

import BpkButton from '../../packages/bpk-component-button';
import BpkDialog, {
HEADER_ICON_TYPES,
} from '../../packages/bpk-component-dialog';
import InfoIcon from '../../packages/bpk-component-icon/lg/information-circle';
import TickIcon from '../../packages/bpk-component-icon/lg/tick';
import TrashIcon from '../../packages/bpk-component-icon/lg/trash';
import BpkText, { TEXT_STYLES } from '../../packages/bpk-component-text';
import { cssModules, withDefaultProps } from '../../packages/bpk-react-utils';

import STYLES from './examples.module.scss';

const getClassName = cssModules(STYLES);

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

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

type State = {
isOpen: boolean,
};

class DialogContainer extends Component<Props, State> {
static propTypes = {
children: PropTypes.node.isRequired,
dismissible: PropTypes.bool,
};

static defaultProps = {
dismissible: true,
headerIcon: null,
};

constructor(props: Props) {
super();

this.state = {
isOpen: props.initiallyOpen || false,
};
}

onOpen = () => {
this.setState({
isOpen: true,
});
};

onClose = () => {
this.setState({
isOpen: false,
});
};

render() {
return (
<div id="dialog-container">
<div id="pagewrap">
<BpkButton onClick={this.onOpen}>Open dialog</BpkButton>
</div>
{/* $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'. */}
<BpkDialog
closeLabel="Close dialog"
id="my-dialog"
ariaLabel="example dialog to showcase component"
className="my-classname"
isOpen={this.state.isOpen}
onClose={this.onClose}
getApplicationElement={() => document.getElementById('pagewrap')}
renderTarget={() => document.getElementById('dialog-container')}
headerIcon
{...this.props}
>
{this.props.children}
<BpkButton onClick={this.onClose}>Close</BpkButton>
</BpkDialog>
</div>
);
}
}

const DefaultExample = () => (
<DialogContainer initiallyOpen>
<Paragraph>
This is a default dialog. You can put anything you want in here.
</Paragraph>
</DialogContainer>
);

const WithIconExample = () => (
<div>
<div>
<span>Default Icon Dialog</span>
<DialogContainer initiallyOpen headerIcon={<TickIcon />} dismissible={false}>
<Paragraph>
This is a default dialog with an icon. You can put anything you want
in here.
</Paragraph>
</DialogContainer>
</div>
<br />
<div>
<span>Warning Icon Dialog</span>
<DialogContainer
headerIcon={<InfoIcon />}
headerIconType={HEADER_ICON_TYPES.warning}
dismissible={false}
>
<Paragraph>
This is a warning dialog with an icon. You can put anything you want
in here.
</Paragraph>
</DialogContainer>
</div>
<br />
<div>
<span>Destructive Icon Dialog</span>
<DialogContainer
headerIcon={<TrashIcon />}
headerIconType={HEADER_ICON_TYPES.destructive}
dismissible={false}
>
<Paragraph>
This is a destructive dialog with an icon. You can put anything you
want in here.
</Paragraph>
</DialogContainer>
</div>
</div>
);

const NotDismissibleExample = () => (
<DialogContainer initiallyOpen dismissible={false}>
<Paragraph>
This is not dismissible. To close it you must bind the `onClose` function
to a component inside the dialog, like the button below.
</Paragraph>
</DialogContainer>
);

const WithFlareExample = () => (
<DialogContainer initiallyOpen flare dismissible={false}>
<Paragraph>
This is a dialog with a flare view added as the header.
</Paragraph>
</DialogContainer>
);

export {
DefaultExample,
WithIconExample,
NotDismissibleExample,
WithFlareExample,
};
Loading

0 comments on commit 5006ce4

Please sign in to comment.