Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Make font-weights themable, fix font faces #19236

Merged
merged 8 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
28 changes: 14 additions & 14 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@
"dom-to-image": "^2.6.0",
"emotion-rgba": "0.0.9",
"fast-glob": "^3.2.7",
"fontsource-fira-code": "^3.0.5",
"fontsource-inter": "^3.0.5",
"fontsource-fira-code": "^4.0.0",
"fontsource-inter": "^4.0.0",
"fs-extra": "^10.0.0",
"fuse.js": "^6.4.6",
"geolib": "^2.0.24",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,38 @@
* under the License.
*/

import React, { CSSProperties, useMemo } from 'react';
import React, { CSSProperties } from 'react';
import { css, styled } from '../../style';
import { t } from '../../translation';

const MESSAGE_STYLES: CSSProperties = { maxWidth: 800 };
const TITLE_STYLES: CSSProperties = {
fontSize: 16,
fontWeight: 'bold',
paddingBottom: 8,
};
const BODY_STYLES: CSSProperties = { fontSize: 14 };
const MIN_WIDTH_FOR_BODY = 250;

const generateContainerStyles: (
height: number | string,
width: number | string,
) => CSSProperties = (height: number | string, width: number | string) => ({
alignItems: 'center',
display: 'flex',
flexDirection: 'column',
height,
justifyContent: 'center',
padding: 16,
textAlign: 'center',
width,
});
const Container = styled.div<{
width: number | string;
height: number | string;
}>`
${({ theme, width, height }) => css`
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
height: ${height}px;
width: ${width}px;
//padding: ${theme.gridUnit * 4}px;
michael-s-molina marked this conversation as resolved.
Show resolved Hide resolved

& .no-results-title {
font-size: ${theme.typography.sizes.l}px;
font-weight: ${theme.typography.weights.bold};
padding-bottom: ${theme.gridUnit * 2};
}

& .no-results-body {
font-size: ${theme.typography.sizes.m}px;
}
`}
`;

type Props = {
className?: string;
Expand All @@ -51,11 +58,6 @@ type Props = {
};

const NoResultsComponent = ({ className, height, id, width }: Props) => {
const containerStyles = useMemo(
() => generateContainerStyles(height, width),
[height, width],
);

// render the body if the width is auto/100% or greater than 250 pixels
const shouldRenderBody =
typeof width === 'string' || width > MIN_WIDTH_FOR_BODY;
Expand All @@ -65,17 +67,20 @@ const NoResultsComponent = ({ className, height, id, width }: Props) => {
);

return (
<div
<Container
height={height}
width={width}
className={className}
id={id}
style={containerStyles}
title={shouldRenderBody ? undefined : BODY_STRING}
>
<div style={MESSAGE_STYLES}>
<div style={TITLE_STYLES}>{t('No Results')}</div>
{shouldRenderBody && <div style={BODY_STYLES}>{BODY_STRING}</div>}
<div className="no-results-title">{t('No Results')}</div>
{shouldRenderBody && (
<div className="no-results-body">{BODY_STRING}</div>
)}
</div>
</div>
</Container>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ const defaultTheme = {
weights: {
light: 200,
normal: 400,
bold: 700,
medium: 500,
bold: 600,
},
sizes: {
xxs: 9,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
*/

import React from 'react';
import { mount } from 'enzyme';
import mockConsole, { RestoreConsole } from 'jest-mock-console';
import { triggerResizeObserver } from 'resize-observer-polyfill';
import ErrorBoundary from 'react-error-boundary';

import { promiseTimeout, SuperChart } from '@superset-ui/core';
// @ts-ignore
// eslint-disable-next-line import/no-extraneous-dependencies
michael-s-molina marked this conversation as resolved.
Show resolved Hide resolved
import { styledMount as mount } from 'spec/helpers/theming';
import RealSuperChart, {
WrapperProps,
} from '../../../src/chart/components/SuperChart';
Expand Down Expand Up @@ -303,6 +305,7 @@ describe('SuperChart', () => {
height="125"
/>,
);
// @ts-ignore
triggerResizeObserver([{ contentRect: { height: 125, width: 150 } }]);

return promiseTimeout(() => {
Expand All @@ -328,6 +331,7 @@ describe('SuperChart', () => {
height="25%"
/>,
);
// @ts-ignore
triggerResizeObserver([{ contentRect: { height: 75, width: 50 } }]);

return promiseTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export default styled(SankeyComponent)`
background: #ddd;
padding: 10px;
font-size: ${({ fontSize }) => fontSize}em;
font-weight: ${({ theme }) => theme.typography.weights.light};
color: #000;
border: 1px solid #fff;
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,11 @@ export default styled(BigNumberVis)`
}

.kicker {
font-weight: ${({ theme }) => theme.typography.weights.light};
line-height: 1em;
padding-bottom: 2em;
}

.header-line {
font-weight: ${({ theme }) => theme.typography.weights.normal};
position: relative;
line-height: 1em;
span {
Expand All @@ -318,7 +316,6 @@ export default styled(BigNumberVis)`
}

.subheader-line {
font-weight: ${({ theme }) => theme.typography.weights.light};
line-height: 1em;
padding-bottom: 0;
}
Expand Down
Loading