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] VisuallyHidden to export props + move it to core #478

Merged
merged 1 commit into from
Jun 18, 2021
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
35 changes: 0 additions & 35 deletions src/components/Visually-hidden/Visually-hidden.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ export {
} from './LanguageMenu/LanguageMenu';
export { Paragraph, ParagraphProps } from './Paragraph/Paragraph';
export { Text, TextProps } from './Text/Text';
export { VisuallyHidden } from './Visually-hidden/Visually-hidden';
2 changes: 1 addition & 1 deletion src/core/Chip/Chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classnames from 'classnames';
import { default as styled } from 'styled-components';
import { logger } from '../../../utils/logger';
import { HtmlButton, HtmlButtonProps, HtmlSpan } from '../../../reset';
import { VisuallyHidden } from '../../../components/Visually-hidden/Visually-hidden';
import { VisuallyHidden } from '../../VisuallyHidden/VisuallyHidden';
import { Icon } from '../../Icon/Icon';
import {
BaseChipProps,
Expand Down
2 changes: 1 addition & 1 deletion src/core/Expander/ExpanderGroup/ExpanderGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component, ReactNode } from 'react';
import { default as styled } from 'styled-components';
import classnames from 'classnames';
import { HtmlDiv, HtmlButton, HtmlButtonProps, HtmlSpan } from '../../../reset';
import { VisuallyHidden } from '../../../components';
import { VisuallyHidden } from '../../VisuallyHidden/VisuallyHidden';
import { baseStyles } from './ExpanderGroup.baseStyles';

const baseClassName = 'fi-expander-group';
Expand Down
2 changes: 1 addition & 1 deletion src/core/Expander/ExpanderTitle/ExpanderTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
HtmlSpan,
} from '../../../reset';
import { Icon } from '../../Icon/Icon';
import { VisuallyHidden } from '../../../components';
import { VisuallyHidden } from '../../VisuallyHidden/VisuallyHidden';
import { ExpanderConsumer, ExpanderTitleBaseProps } from '../Expander/Expander';
import { expanderTitleBaseStyles } from './ExpanderTitle.baseStyles';

Expand Down
2 changes: 1 addition & 1 deletion src/core/Form/LabelText/LabelText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classnames from 'classnames';
import { default as styled } from 'styled-components';
import { baseStyles } from './LabelText.baseStyles';
import { asPropType } from '../../../utils/typescript';
import { VisuallyHidden } from '../../../components/Visually-hidden/Visually-hidden';
import { VisuallyHidden } from '../../VisuallyHidden/VisuallyHidden';
import { HtmlSpan, HtmlSpanProps, HtmlDiv, HtmlDivProps } from '../../../reset';

export type LabelMode = 'hidden' | 'visible';
Expand Down
2 changes: 1 addition & 1 deletion src/core/Form/RadioButton/RadioButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component, ReactNode } from 'react';
import { default as styled } from 'styled-components';
import { HtmlDiv, HtmlSpan, HtmlFieldSet, HtmlLegend } from '../../../reset';
import { VisuallyHidden } from '../../../components/Visually-hidden/Visually-hidden';
import { VisuallyHidden } from '../../VisuallyHidden/VisuallyHidden';
import { RadioButtonProps } from './RadioButton';
import { baseStyles } from './RadioButtonGroup.baseStyles';
import { AutoId } from '../../../utils/AutoId';
Expand Down
2 changes: 1 addition & 1 deletion src/core/Form/SearchInput/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
HtmlButton,
HtmlButtonProps,
} from '../../../reset';
import { VisuallyHidden } from '../../../components/Visually-hidden/Visually-hidden';
import { VisuallyHidden } from '../../VisuallyHidden/VisuallyHidden';
import { StatusText } from '../StatusText/StatusText';
import { LabelText, LabelMode } from '../LabelText/LabelText';
import { Icon } from '../../Icon/Icon';
Expand Down
2 changes: 1 addition & 1 deletion src/core/Link/LinkExternal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '../../components/Link/LinkExternal';
import { Icon } from '../Icon/Icon';
import { Link, LinkProps } from './Link';
import { VisuallyHidden } from '../../components';
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden';
import { externalStyles } from './Link.baseStyles';

const iconClassName = 'fi-link_icon';
Expand Down
36 changes: 35 additions & 1 deletion src/core/VisuallyHidden/VisuallyHidden.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
export { VisuallyHidden } from '../../components/Visually-hidden/Visually-hidden';
import React, { Component } from 'react';
import { default as styled } from 'styled-components';
import classnames from 'classnames';
import { HtmlSpan, HtmlSpanProps } from '../../reset/HtmlSpan/HtmlSpan';

export interface VisuallyHiddenProps extends HtmlSpanProps {
className?: string;
}

const baseClassName = 'fi-visually-hidden';

const StyledVisuallyHidden = styled((props: VisuallyHiddenProps) => (
<HtmlSpan {...props} />
))`
position: absolute;
clip: rect(0 0 0 0);
height: 1px;
width: 1px;
margin: -1px;
padding: 0;
border: 0;
overflow: hidden;
`;

export class VisuallyHidden extends Component<VisuallyHiddenProps> {
render() {
const { className, ...passProps } = this.props;
return (
<StyledVisuallyHidden
{...passProps}
className={classnames(baseClassName, className)}
/>
);
}
}
5 changes: 4 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,8 @@ export {
export { Paragraph, ParagraphProps } from './core/Paragraph/Paragraph';
export { Text, TextProps } from './core/Text/Text';
export { Textarea, TextareaProps } from './core/Form/Textarea/Textarea';
export { VisuallyHidden } from './core/VisuallyHidden/VisuallyHidden';
export {
VisuallyHidden,
VisuallyHiddenProps,
} from './core/VisuallyHidden/VisuallyHidden';
export { suomifiDesignTokens, DesignTokens } from 'suomifi-design-tokens';