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

Fix Alert and AlertInCard typing. Allow empty title #102

Merged
merged 2 commits into from
Jun 17, 2020
Merged
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
7 changes: 7 additions & 0 deletions packages/flame/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Refer to the [CONTRIBUTING guide](https://github.com/lightspeed/flame/blob/master/.github/CONTRIBUTING.md) for more info.

## [Unreleased]

### Fixed

- Fix typing for Alert and AlertInCard ([#102](https://github.com/lightspeed/flame/pull/102)
- Allow empty Alert title and adjust positioning if its the case ([#102](https://github.com/lightspeed/flame/pull/102)

## 2.0.0-rc.3 - 2020-06-17

- Version bump because lerna
Expand Down
11 changes: 7 additions & 4 deletions packages/flame/src/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Text } from '../Text';

export type AlertTypes = 'info' | 'success' | 'warning' | 'danger' | string;

export interface AlertProps {
export interface AlertProps extends SpaceProps, React.ComponentPropsWithRef<'div'> {
/** CSS class name */
className?: string;
/** Enum for preset Alert types */
Expand All @@ -22,12 +22,12 @@ export interface AlertProps {
/** Icon for the alert */
icon?: React.ReactNode;
/** Text for the alert's title */
title: string;
title?: string;
}
/**
* An alert can be a warning following an action, a helpful tip or an important update about a system issue. There are four types of alert and each has a different function.
*/
export const Alert: React.FC<AlertProps & SpaceProps> = ({
export const Alert: React.FC<AlertProps> = ({
children,
type = 'info',
title,
Expand Down Expand Up @@ -72,7 +72,10 @@ export const Alert: React.FC<AlertProps & SpaceProps> = ({
>
<Flex flex="1">
<Box flex="1" css={css({ position: 'relative', pl: 5 })}>
<Flex className="fl-alert__icon" css={{ position: 'absolute', left: '0px', top: '2px' }}>
<Flex
className="fl-alert__icon"
css={{ position: 'absolute', left: '0px', top: title ? '2px' : '1px' }}
>
{icon || <AlertIcons type={type} />}
</Flex>
{title && (
Expand Down
3 changes: 2 additions & 1 deletion packages/flame/src/Alert/AlertInCard.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as React from 'react';
import css from '@styled-system/css';

import { SpaceProps } from 'styled-system';
import { AlertIcons } from './AlertIcons';
import { CloseButton } from './CloseButton';
import { Flex } from '../Core';
import { Text } from '../Text';

interface Props {
interface Props extends SpaceProps, React.ComponentPropsWithRef<'div'> {
type?: string;
noCloseBtn?: boolean;
/** Function called when Close button is tapped */
Expand Down