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

Revert "Implement new inputs and select components" #47134

Closed
wants to merge 1 commit into from
Closed
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 web/packages/design/src/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface CheckboxInputProps {
disabled?: boolean;
id?: string;
name?: string;
readOnly?: boolean;
readonly?: boolean;
role?: string;
type?: 'checkbox' | 'radio';
value?: string;
Expand Down
20 changes: 17 additions & 3 deletions web/packages/design/src/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import React, { PropsWithChildren } from 'react';
import styled from 'styled-components';

import { space, color, borderRadius, SpaceProps } from 'design/system';
import { space, color, borderRadius } from 'design/system';

export function Icon({
size = 'medium',
Expand Down Expand Up @@ -65,14 +65,28 @@ const StyledIcon = styled.span`

export type IconSize = 'small' | 'medium' | 'large' | 'extraLarge' | number;

export type IconProps = SpaceProps & {
export type IconProps = {
size?: IconSize;
color?: string;
title?: string;
m?: number | string;
mr?: number | string;
ml?: number | string;
mb?: number | string;
mt?: number | string;
my?: number | string;
mx?: number | string;
p?: number | string;
pr?: number | string;
pl?: number | string;
pb?: number | string;
pt?: number | string;
py?: number | string;
px?: number | string;
role?: string;
style?: React.CSSProperties;
borderRadius?: number;
onClick?: React.MouseEventHandler;
onClick?: () => void;
disabled?: boolean;
as?: any;
to?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/*
* Teleport
* Copyright (C) 2024 Gravitational, Inc.
* Copyright (C) 2023 Gravitational, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand All @@ -16,16 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

// Declare custom props via module augmentation, per
// https://react-select.com/typescript#custom-select-props
import React from 'react';

import type {} from 'react-select/base';
// This import is necessary for module augmentation.
// It allows us to extend the 'Props' interface in the 'react-select/base' module
// and add our custom property 'myCustomProp' to it.
import Input from '.';

declare module 'react-select/base' {
export interface Props {
customProps?: Record<string, any>;
}
}
export default {
title: 'Design/Inputs',
};

export const Inputs = () => (
<>
<Input mb={4} placeholder="Enter SomeText" />
<Input mb={4} hasError={true} defaultValue="This field has an error" />
<Input mb={4} readOnly defaultValue="Read-only field" />
<Input mb={4} disabled defaultValue="Disabled field" />
</>
);
91 changes: 0 additions & 91 deletions web/packages/design/src/Input/Input.story.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,15 @@

import React from 'react';

import { render, screen, theme } from 'design/utils/testing';
import { render, theme } from 'design/utils/testing';

import Input from './Input';

describe('design/Input', () => {
it('forwards a ref', () => {
const ref = jest.fn();
render(<Input ref={ref} defaultValue="foo" />);
expect(ref).toHaveBeenCalledWith(expect.objectContaining({ value: 'foo' }));
});
it('respects hasError prop', () => {
render(<Input hasError={true} />);
expect(screen.getByRole('textbox')).toHaveStyle({
'border-color': theme.colors.interactive.solid.danger.default.background,
let { container } = render(<Input hasError={true} />);
expect(container.firstChild).toHaveStyle({
'border-color': theme.colors.error.main,
});
expect(screen.getByRole('graphics-symbol')).toHaveAttribute(
'aria-label',
'Error'
);
});
});
Loading
Loading