Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/demo-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const gitPagesUrl = `https://${parsedGitUrl.owner}.github.io/${parsedGitUrl.name
console.log('Publish storybook demo for github');
console.log('=> Build storybook');
shell.exec(`yarn build-storybook -o ${tempOutputDir}`, { fatal: true });
shell.exec(`STORYBOOK_BUILD_DIR=${tempOutputDir} node bin/generate-docs-urls.js`)
shell.exec(`STORYBOOK_BUILD_DIR=${tempOutputDir} node bin/generate-docs-urls.js`);

// Prepare temporary gh-pages dir
console.log('=> Prepare temporary dir');
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions packages/amount/src/__snapshots__/component.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
exports[`Amount should match snapshots for base and Pure components 1`] = `
<div>
<span
class="component"
class="component default"
>

1
<span
class="minorPartAndCurrency"
class="minorPartAndCurrency defaultMinor"
>


Expand All @@ -28,24 +28,24 @@ exports[`Amount should match snapshots for base and Pure components 1`] = `
exports[`Amount should not render plus sign when showPlus and value <= 0 1`] = `
<div>
<span
class="component"
class="component default"
>

0
<span
class="minorPartAndCurrency"
class="minorPartAndCurrency defaultMinor"
>


</span>
</span>
<span
class="component"
class="component default"
>

−1
<span
class="minorPartAndCurrency"
class="minorPartAndCurrency defaultMinor"
>


Expand All @@ -69,12 +69,12 @@ exports[`Amount should not render plus sign when showPlus and value <= 0 1`] = `
exports[`Amount should render plus sign when showPlus and value > 0 1`] = `
<div>
<span
class="component"
class="component default"
>
+
1
<span
class="minorPartAndCurrency"
class="minorPartAndCurrency defaultMinor"
>


Expand All @@ -92,12 +92,12 @@ exports[`Amount should render plus sign when showPlus and value > 0 1`] = `
exports[`Amount should render rightAddons 1`] = `
<div>
<span
class="component"
class="component default"
>

1
<span
class="minorPartAndCurrency"
class="minorPartAndCurrency defaultMinor"
>


Expand Down
19 changes: 17 additions & 2 deletions packages/amount/src/component.screenshots.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,33 @@ describe(
screenshotTesting({
cases: [
[
'sprite',
'main',
createSpriteStorybookUrl({
componentName: 'Amount',
knobs: {
value: [12300],
value: 12300,
currency: ['RUR', 'USD'],
minority: [100, 10],
view: ['default', 'withZeroMinorPart'],
},
size: { width: 100, height: 50 },
}),
],
[
'styles',
createSpriteStorybookUrl({
componentName: 'Amount',
knobs: {
value: 12300,
currency: 'RUR',
minority: 100,
view: 'withZeroMinorPart',
bold: ['none', 'full', 'major'],
transparentMinor: [false, true],
},
size: { width: 100, height: 50 },
}),
],
],
}),
);
21 changes: 19 additions & 2 deletions packages/amount/src/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const Amount: React.FC<AmountProps> = ({
minority,
currency,
view = 'default',
bold,
transparentMinor,
rightAddons,
showPlus = false,
className,
Expand All @@ -26,11 +28,26 @@ export const Amount: React.FC<AmountProps> = ({
view,
});

const defaultStyles = bold === undefined && transparentMinor === undefined;

return (
<span className={cn(styles.component, className)} data-test-id={dataTestId}>
<span
className={cn(styles.component, className, {
[styles.bold]: bold === 'full',
[styles.boldMajor]: bold === 'major',
[styles.default]: defaultStyles,
})}
data-test-id={dataTestId}
>
{showPlus && value > 0 ? '+' : ''}
{majorPart}
<span className={styles.minorPartAndCurrency}>
<span
className={cn(styles.minorPartAndCurrency, {
[styles.transparentMinor]: transparentMinor,
[styles.normalMinor]: bold === 'major',
[styles.defaultMinor]: defaultStyles,
})}
>
{minorPart && AMOUNT_MAJOR_MINOR_PARTS_SEPARATOR}
{minorPart}
{currency ? `${THINSP}${currencySymbol}` : null}
Expand Down
12 changes: 5 additions & 7 deletions packages/amount/src/docs/component.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import styles from '!!raw-loader!../index.module.css';
<Story name='Amount'>
{React.createElement(() => {
const currencyCodes = getAllCurrencyCodes();
const value = number('value', 12300);
const value = number('value', 10099);
const currency = select('currency', currencyCodes, 'RUR');
const minority = number('minority', 100);
const showPlus = boolean('showPlus', false);
const view = select('view', ['default', 'withZeroMinorPart'], 'default');
const className = select('className', '');
const dataTestId = text('dataTestId', '');
const bold = select('bold', ['full', 'major', 'none'], 'bold');
const transparentMinor = boolean('transparentMinor', true);
return (
<Container>
<Row>
Expand All @@ -43,8 +43,8 @@ import styles from '!!raw-loader!../index.module.css';
minority={minority}
showPlus={showPlus}
view={view}
className={className}
dataTestId={dataTestId}
bold={bold}
transparentMinor={transparentMinor}
/>
</Col>
<Col>
Expand All @@ -54,8 +54,6 @@ import styles from '!!raw-loader!../index.module.css';
minority={minority}
showPlus={showPlus}
view={view}
className={className}
dataTestId={dataTestId}
/>
</Col>
</Row>
Expand Down
24 changes: 22 additions & 2 deletions packages/amount/src/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,34 @@
:root {
--amount-major-part-font-weight: bold;
--amount-minor-part-font-weight: normal;
--amount-minor-part-opacity: 0.6;
}

.component {
white-space: nowrap;
font-weight: var(--amount-major-part-font-weight);
}

.minorPartAndCurrency {
.transparentMinor {
opacity: 0.6;
}

.bold {
font-weight: bold;
}

.boldMajor {
font-weight: bold;
}

.normalMinor {
font-weight: normal;
}

.default {
font-weight: var(--amount-major-part-font-weight);
}

.defaultMinor {
opacity: var(--amount-minor-part-opacity);
font-weight: var(--amount-minor-part-font-weight);
}
10 changes: 10 additions & 0 deletions packages/amount/src/types/amount-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ export type AmountProps = {
*/
view?: 'default' | 'withZeroMinorPart';

/**
* Управление жирностью
*/
bold?: 'full' | 'major' | 'none';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно заменить на | false. Но хз)


/**
* Делает минорную часть полупрозрачной
*/
transparentMinor?: boolean;

/**
* Показывать значок + для положительных значений
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/bottom-sheet/src/component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describe('Bottom sheet', () => {
fireEvent.click(content);
}

await new Promise((res) => setTimeout(res, 1000));
await new Promise(res => setTimeout(res, 1000));

expect(queryByTestId(dataTestId)).toBeInTheDocument();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/bottom-sheet/src/components/closer/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const Closer: React.FC<CloserProps> = ({
const { onClose } = useContext(BaseModalContext);

const handleClick = useCallback(
(event) => {
event => {
onClose(event, 'closerClick');
},
[onClose],
Expand Down
2 changes: 1 addition & 1 deletion packages/codemod/src/button-xs/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const buttonTransform: Transform = (fileInfo, api) => {
/**
* Находим использование компонента Tag и меняем ему пропсы
*/
source.findJSXElements('Tag').forEach(path => {
source.findJSXElements('Tag').forEach(path => {
j(path).replaceWith((path: ASTPath<JSXElement>) => {
const { node } = path;

Expand Down
1 change: 0 additions & 1 deletion packages/confirmation/src/components/screens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export * from './initial';
export * from './hint';
export * from './fatal-error';
export * from './temp-block';

4 changes: 3 additions & 1 deletion packages/date-input/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ describe('DateInput', () => {
const onChange = jest.fn();
const onComplete = jest.fn();
const value = '01.01.2020';
const { queryByRole } = render(<DateInput onChange={onChange} onComplete={onComplete} />);
const { queryByRole } = render(
<DateInput onChange={onChange} onComplete={onComplete} />,
);

const input = queryByRole('textbox') as HTMLInputElement;

Expand Down
2 changes: 1 addition & 1 deletion packages/file-upload-item/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('FileUploadItem', () => {
expect(cb.mock.calls[0][0]).toBe(fileId);
});

it('should call `onDownload` prop', async() => {
it('should call `onDownload` prop', async () => {
const cb = jest.fn();
const fileId = 'id';
const { baseElement } = render(
Expand Down
5 changes: 3 additions & 2 deletions packages/file-upload-item/src/component.screenshots.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,15 @@ describe(
}),
);


describe(
'FileUploadItem | ellipsis',
screenshotTesting({
cases: generateTestCases({
componentName: 'FileUploadItem',
knobs: {
name: ['very-long-file-name-123-very-long-file-name-123-very-long-file-name-123.jpg'],
name: [
'very-long-file-name-123-very-long-file-name-123-very-long-file-name-123.jpg',
],
uploadDate: ['22.01.2018'],
size: [45000],
showRestore: [true],
Expand Down
6 changes: 1 addition & 5 deletions packages/screenshot-utils/screenshots-story/components.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
const req = require.context(
'../../',
true,
/^\.\/(.*)\/src\/index.ts$/,
);
const req = require.context('../../', true, /^\.\/(.*)\/src\/index.ts$/);

const packages = req.keys().reduce((acc, key) => {
const packageName = key.split('/')[1];
Expand Down
2 changes: 1 addition & 1 deletion packages/themes/src/mixins/click.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
--disabled-cursor: not-allowed;
--arrow-transform: rotate(-180deg);

@mixin amount-click;
@mixin form-control-click;
@mixin input-click;
@mixin button-click;
Expand All @@ -51,4 +50,5 @@
@mixin dropzone-click;
@mixin code-input-click;
@mixin bottom-sheet-click;
@mixin amount-click;
}
2 changes: 1 addition & 1 deletion packages/tooltip/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as popoverModule from '@alfalab/core-components-popover';
import { Tooltip, TooltipProps } from './index';

jest.mock('react-transition-group', () => {
return { CSSTransition: jest.fn((props) => (props.in ? props.children : null)) };
return { CSSTransition: jest.fn(props => (props.in ? props.children : null)) };
});

type PopoverComponent = {
Expand Down