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

[New] MediumMultilineInput and LargeMultilineInput Elements #766

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
40 changes: 39 additions & 1 deletion packages/fuselage-ui-kit/src/elements/PlainTextInputElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,45 @@ const PlainTextInputElement = ({
}: PlainTextInputElementProps): ReactElement => {
const [{ loading, value, error }, action] = useUiKitState(block, context);

if (block.multiline) {
if (block.multiline && block.multilineSize === 'large') {
return (
<TextAreaInput
disabled={loading}
id={block.actionId}
name={block.actionId}
rows={30}
error={error}
value={value}
onChange={action}
placeholder={
block.placeholder
? fromTextObjectToString(surfaceRenderer, block.placeholder, 0)
: undefined
}
/>
);
}

if (block.multiline && block.multilineSize === 'medium') {
return (
<TextAreaInput
disabled={loading}
id={block.actionId}
name={block.actionId}
rows={15}
error={error}
value={value}
onChange={action}
placeholder={
block.placeholder
? fromTextObjectToString(surfaceRenderer, block.placeholder, 0)
: undefined
}
/>
);
}

if (block.multiline || (block.multiline && block.multilineSize === 'small')) {
return (
<TextAreaInput
disabled={loading}
Expand Down
14 changes: 14 additions & 0 deletions packages/fuselage-ui-kit/src/stories/Banner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ export const InputWithMultilinePlainTextInput = createStory(
}
);

export const InputWithMediumMultilinePlainTextInput = createStory(
payloads.inputWithMediumMultilinePlainTextInput,
{
'input-0': 'Error',
}
);

export const InputWithLargeMultilinePlainTextInput = createStory(
payloads.inputWithLargeMultilinePlainTextInput,
{
'input-0': 'Error',
}
);

export const InputWithPlainTextInput = createStory(
payloads.inputWithPlainTextInput,
{
Expand Down
14 changes: 14 additions & 0 deletions packages/fuselage-ui-kit/src/stories/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ export const InputWithMultilinePlainTextInput = createStory(
}
);

export const InputWithMediumMultilinePlainTextInput = createStory(
payloads.inputWithMediumMultilinePlainTextInput,
{
'input-0': 'Error',
}
);

export const InputWithLargeMultilinePlainTextInput = createStory(
payloads.inputWithLargeMultilinePlainTextInput,
{
'input-0': 'Error',
}
);

export const InputWithPlainTextInput = createStory(
payloads.inputWithPlainTextInput,
{
Expand Down
41 changes: 41 additions & 0 deletions packages/fuselage-ui-kit/src/stories/payloads/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const inputWithMultilinePlainTextInput: readonly UiKit.LayoutBlock[] = [
blockId: 'dummy-block-id',
type: 'plain_text_input',
multiline: true,
multilineSize: 'small',
actionId: 'input-0',
},
label: {
Expand All @@ -18,6 +19,46 @@ export const inputWithMultilinePlainTextInput: readonly UiKit.LayoutBlock[] = [
},
] as const;

export const inputWithMediumMultilinePlainTextInput: readonly UiKit.LayoutBlock[] =
[
{
type: 'input',
element: {
appId: 'dummy-app-id',
blockId: 'dummy-block-id',
type: 'plain_text_input',
multiline: true,
multilineSize: 'medium',
actionId: 'input-0',
},
label: {
type: 'plain_text',
text: 'Label',
emoji: true,
},
},
] as const;

export const inputWithLargeMultilinePlainTextInput: readonly UiKit.LayoutBlock[] =
[
{
type: 'input',
element: {
appId: 'dummy-app-id',
blockId: 'dummy-block-id',
type: 'plain_text_input',
multiline: true,
multilineSize: 'large',
actionId: 'input-0',
},
label: {
type: 'plain_text',
text: 'Label',
emoji: true,
},
},
] as const;

export const inputWithPlainTextInput: readonly UiKit.LayoutBlock[] = [
{
type: 'input',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export type PlainTextInputElement = Actionable<{
multiline?: boolean;
minLength?: number;
maxLength?: number;
multilineSize?: 'large' | 'medium' | 'small';
}>;