Skip to content

Commit

Permalink
Merge branch 'main' into adam/upgrade-babel
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSonOfThomp committed Apr 2, 2024
2 parents 833ab65 + 04aa188 commit bbb9332
Show file tree
Hide file tree
Showing 26 changed files with 178 additions and 159 deletions.
6 changes: 6 additions & 0 deletions .changeset/quick-tables-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@leafygreen-ui/loading-indicator': patch
---

- Horizontally centers loading indicator with description
- Deletes duplicate `LoadingIndicators.styles.ts` file
5 changes: 5 additions & 0 deletions .changeset/twenty-hotels-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/logo': minor
---

Exports `LogoProps` from package
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ coverage/

# Exported TSDocs example files
parsed-docs.json
packages/**/tsdoc.json
**/tsdoc.json

# Compiled story files
packages/**/stories.js*
**/stories.js*

# Local yarn releases
.yarn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ const Template: StoryFn<typeof Spinner> = (

export const LiveExample = Template.bind({});
LiveExample.args = {
description: 'Loading...',
description: 'Loading dot dot...',
};
7 changes: 0 additions & 7 deletions packages/loading-indicator/src/LoadingIndicators.styles.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export const Default = Template.bind({});

export const WithDescription = Template.bind({});
WithDescription.args = {
description: 'Loading...',
description: 'Loading dot dot...',
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ export const blobStyles = {
};

export const rootStyles = css`
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
`;
4 changes: 2 additions & 2 deletions packages/loading-indicator/src/Spinner/Spinner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export const Default = Template.bind({});

export const WithDescription = Template.bind({});
WithDescription.args = {
description: 'Loading...',
description: 'Loading dot dot...',
};

export const Horizontal = Template.bind({});
Horizontal.args = {
displayOption: 'default-horizontal',
description: 'Loading...',
description: 'Loading dot dot...',
};

export const SizeOverride = Template.bind({});
Expand Down
9 changes: 6 additions & 3 deletions packages/loading-indicator/src/Spinner/Spinner.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export const SpinnerBottomMargins: Record<DisplayOption, number> = {

// Styles
export const rootStyles = css`
text-align: center;
display: flex;
align-items: center;
`;

export const darkModeSpinnerStyles = css`
Expand All @@ -37,7 +38,9 @@ export const colorOverrideStyles = (color: string) => css`
`;

export const horizontalDisplayOptionStyles = css`
display: flex;
align-items: center;
gap: 6px;
`;

export const verticalDisplayOptionStyles = css`
flex-direction: column;
`;
3 changes: 3 additions & 0 deletions packages/loading-indicator/src/Spinner/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
rootStyles,
SpinnerBottomMargins,
SpinnerSizes,
verticalDisplayOptionStyles,
} from './Spinner.styles';
import { DisplayOption, SpinnerProps } from './Spinner.types';

Expand Down Expand Up @@ -45,6 +46,8 @@ const Spinner = ({
{
[horizontalDisplayOptionStyles]:
displayOption === DisplayOption.DefaultHorizontal,
[verticalDisplayOptionStyles]:
displayOption !== DisplayOption.DefaultHorizontal,
},
className,
)}
Expand Down
35 changes: 18 additions & 17 deletions packages/logo/src/Logo.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { StoryFn } from '@storybook/react';

import { css } from '@leafygreen-ui/emotion';

import { LogoNames } from './Logo';
import { LogoProps, SupportedColors } from './utils';
import { BaseLogoProps, LogoNames, SupportedColors } from './Logo.types';
import {
AtlasForGovernmentLogoLockup,
AtlasLogoLockup,
Expand Down Expand Up @@ -99,8 +98,8 @@ const divStyle = css`
margin: 0.5rem;
`;

export const LiveExample: StoryFn<LogoProps & { name: LogoName }> = (
args: LogoProps & { name: LogoName },
export const LiveExample: StoryFn<BaseLogoProps & { name: LogoName }> = (
args: BaseLogoProps & { name: LogoName },
) => {
if (!args.name) {
args = { ...args, name: 'MongoDBLogo' };
Expand All @@ -125,9 +124,9 @@ LiveExample.parameters = {

const Template = (
LogoComponent: React.ForwardRefExoticComponent<
Omit<LogoProps, 'ref'> & React.RefAttributes<SVGSVGElement>
Omit<BaseLogoProps, 'ref'> & React.RefAttributes<SVGSVGElement>
>,
args: LogoProps,
args: BaseLogoProps,
) => {
const containerStyle = css`
${divStyle}
Expand All @@ -140,28 +139,30 @@ const Template = (
};

// Individual Components
export const MongoDB = (args: LogoProps) => Template(MongoDBLogo, args);
export const Atlas = (args: LogoProps) => Template(AtlasNavGraphic, args);
export const MongoDBMark = (args: LogoProps) => Template(MongoDBLogoMark, args);
export const AtlasLockup = (args: LogoProps) => Template(AtlasLogoLockup, args);
export const AtlasForGovernmentLockup = (args: LogoProps) =>
export const MongoDB = (args: BaseLogoProps) => Template(MongoDBLogo, args);
export const Atlas = (args: BaseLogoProps) => Template(AtlasNavGraphic, args);
export const MongoDBMark = (args: BaseLogoProps) =>
Template(MongoDBLogoMark, args);
export const AtlasLockup = (args: BaseLogoProps) =>
Template(AtlasLogoLockup, args);
export const AtlasForGovernmentLockup = (args: BaseLogoProps) =>
Template(AtlasForGovernmentLogoLockup, args);
export const EnterpriseAdvancedLockup = (args: LogoProps) =>
export const EnterpriseAdvancedLockup = (args: BaseLogoProps) =>
Template(EnterpriseAdvancedLogoLockup, args);
export const CommunityEditionLockup = (args: LogoProps) =>
export const CommunityEditionLockup = (args: BaseLogoProps) =>
Template(CommunityEditionLogoLockup, args);
export const UniversityLockup = (args: LogoProps) =>
export const UniversityLockup = (args: BaseLogoProps) =>
Template(UniversityLogoLockup, args);

// Deprecated
// @ts-ignore deprecated component
export const AtlasMark = (args: LogoProps) => Template(AtlasLogoMark, args);
export const AtlasMark = (args: BaseLogoProps) => Template(AtlasLogoMark, args);
AtlasMark.storyName = '[DEPRECATED] Atlas Mark';
// @ts-ignore deprecated component
export const RealmMark = (args: LogoProps) => Template(RealmLogoMark, args);
export const RealmMark = (args: BaseLogoProps) => Template(RealmLogoMark, args);
RealmMark.storyName = '[DEPRECATED] Realm Mark';
// @ts-ignore deprecated component
export const ChartsMark = (args: LogoProps) => Template(ChartsLogoMark, args);
export const ChartsMark = args => Template(ChartsLogoMark, args);
ChartsMark.storyName = '[DEPRECATED] Charts Mark';

export const Generated = () => {};
25 changes: 2 additions & 23 deletions packages/logo/src/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { LogoProps } from './utils';
import { LogoProps } from './Logo.types';
import {
AtlasForGovernmentLogoLockup,
AtlasLogoLockup,
Expand All @@ -12,35 +12,14 @@ import {
UniversityLogoLockup,
} from '.';

export const LogoNames = [
'MongoDBLogoMark',
'MongoDBLogo',
'AtlasNavGraphic',
'AtlasLogoLockup',
'AtlasForGovernmentLogoLockup',
'EnterpriseAdvancedLogoLockup',
'CommunityEditionLogoLockup',
'UniversityLogoLockup',
] as const;

export type LogoName = (typeof LogoNames)[number];

interface GenericLogoProps extends LogoProps {
/**
* The name of the logo to render
* @required
*/
name: LogoName;
}

/**
* A generic logo component that accepts a logo name as well as other LogoProps.
*
* Note: For performance, it's recommended to import a specific logo explicitly rather than rely on this generic component
*/
const GenericLogo = React.forwardRef(
(
{ name = 'MongoDBLogo', ...rest }: GenericLogoProps,
{ name = 'MongoDBLogo', ...rest }: LogoProps,
ref: React.Ref<SVGSVGElement> | undefined,
) => {
const LogoMap = {
Expand Down
73 changes: 19 additions & 54 deletions packages/logo/src/utils.ts → packages/logo/src/Logo.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { css } from '@leafygreen-ui/emotion';
import { HTMLElementProps } from '@leafygreen-ui/lib';
import { palette } from '@leafygreen-ui/palette';

Expand All @@ -23,7 +22,7 @@ type SupportedColorsMap =

export { SupportedColors, SupportedColorsMap };

export interface LogoProps extends HTMLElementProps<'svg'> {
export interface BaseLogoProps extends HTMLElementProps<'svg'> {
/**
* Determines Color of the Logo or LogoMark component.
*
Expand All @@ -46,57 +45,23 @@ export type ProductLogoProps = HTMLElementProps<'svg', never> & {
height?: number;
};

export const getAccessibleProps = ({
role,
'aria-label': ariaLabel,
}: {
role: string;
'aria-label': string;
}) => {
if (role === 'img') {
return {
role: 'img',
'aria-label': ariaLabel,
};
}
export const LogoNames = [
'MongoDBLogoMark',
'MongoDBLogo',
'AtlasNavGraphic',
'AtlasLogoLockup',
'AtlasForGovernmentLogoLockup',
'EnterpriseAdvancedLogoLockup',
'CommunityEditionLogoLockup',
'UniversityLogoLockup',
] as const;

return {
role: 'presentation',
alt: '',
'aria-hidden': true,
};
};

export const getColor = ({
knockout,
size,
flat,
gradient,
darkMode,
}: {
knockout: boolean;
darkMode: boolean;
size: number;
flat: string;
gradient: string;
}) => {
let fill;
export type LogoName = (typeof LogoNames)[number];

if (!knockout) {
if (size <= 10) {
fill = flat;
} else {
fill = gradient;
}
} else {
if (darkMode) {
fill = palette.white;
} else {
fill = palette.black;
}
}

return css`
fill: ${fill};
`;
};
export interface LogoProps extends BaseLogoProps {
/**
* The name of the logo to render
* @required
*/
name: LogoName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import PropTypes from 'prop-types';
import { css, cx } from '@leafygreen-ui/emotion';

import {
getAccessibleProps,
LogoProps,
BaseLogoProps,
SupportedColors,
SupportedColorsMap,
} from './utils';
} from '../Logo.types';
import { getAccessibleProps } from '../utils';

/**
* # AtlasForGovernmentLogoLockup
Expand All @@ -30,7 +30,7 @@ export const AtlasForGovernmentLogoLockup = React.forwardRef(
role = 'img',
'aria-label': ariaLabel = 'MongoDB Logo',
...rest
}: LogoProps,
}: BaseLogoProps,
ref: React.LegacyRef<SVGSVGElement> | undefined,
): ReactElement => {
const fill = SupportedColorsMap[color];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import PropTypes from 'prop-types';
import { css, cx } from '@leafygreen-ui/emotion';

import {
getAccessibleProps,
LogoProps,
BaseLogoProps,
SupportedColors,
SupportedColorsMap,
} from './utils';
} from '../Logo.types';
import { getAccessibleProps } from '../utils';

/**
* # AtlasLogoLockup
Expand All @@ -32,7 +32,7 @@ export const AtlasLogoLockup = React.forwardRef(
role = 'img',
'aria-label': ariaLabel = 'MongoDB Logo',
...rest
}: LogoProps,
}: BaseLogoProps,
ref: React.LegacyRef<SVGSVGElement> | undefined,
): ReactElement => {
const fill = SupportedColorsMap[color];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react';

import { css, cx } from '@leafygreen-ui/emotion';

import { getAccessibleProps, getColor, ProductLogoProps } from './utils';
import { ProductLogoProps } from '../Logo.types';
import { getAccessibleProps, getColor } from '../utils';

/**
* @deprecated
Expand Down
Loading

0 comments on commit bbb9332

Please sign in to comment.