Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
19 changes: 19 additions & 0 deletions packages/storybook/src/stories/text-area.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ScoutTextArea } from "@scouterna/ui-react";
import preview from "#.storybook/preview";

const meta = preview.meta({
title: "Uncategorized/Text-Area",
component: ScoutTextArea,
parameters: {
layout: "centered",
},
});

export default meta;

export const BasicExample = meta.story({
args: {
label: "",
},
render: (args) => <ScoutTextArea {...args} />,
});
12 changes: 12 additions & 0 deletions packages/ui-react/lib/components/stencil-generated/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { ScoutLoader as ScoutLoaderElement, defineCustomElement as defineScoutLo
import { ScoutSelect as ScoutSelectElement, defineCustomElement as defineScoutSelect } from "@scouterna/ui-webc/dist/components/scout-select.js";
import { ScoutStack as ScoutStackElement, defineCustomElement as defineScoutStack } from "@scouterna/ui-webc/dist/components/scout-stack.js";
import { ScoutSwitch as ScoutSwitchElement, defineCustomElement as defineScoutSwitch } from "@scouterna/ui-webc/dist/components/scout-switch.js";
import { ScoutTextArea as ScoutTextAreaElement, defineCustomElement as defineScoutTextArea } from "@scouterna/ui-webc/dist/components/scout-text-area.js";
import type { EventName, StencilReactComponent } from '@stencil/react-output-target/runtime';
import { createComponent } from '@stencil/react-output-target/runtime';
import React from 'react';
Expand Down Expand Up @@ -243,3 +244,14 @@ export const ScoutSwitch: StencilReactComponent<ScoutSwitchElement, ScoutSwitchE
} as ScoutSwitchEvents,
defineCustomElement: defineScoutSwitch
});

export type ScoutTextAreaEvents = NonNullable<unknown>;

export const ScoutTextArea: StencilReactComponent<ScoutTextAreaElement, ScoutTextAreaEvents> = /*@__PURE__*/ createComponent<ScoutTextAreaElement, ScoutTextAreaEvents>({
tagName: 'scout-text-area',
elementClass: ScoutTextAreaElement,
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
react: React,
events: {} as ScoutTextAreaEvents,
defineCustomElement: defineScoutTextArea
});
37 changes: 37 additions & 0 deletions packages/ui-webc/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,20 @@ export namespace Components {
*/
"toggled": boolean;
}
interface ScoutTextArea {
/**
* @default false
*/
"autofocus": boolean;
"disabled"?: boolean;
"form": string;
"label"?: string;
"maxLength"?: number;
"placeholder"?: string;
"readOnly"?: boolean;
"required"?: boolean;
"value"?: string;
}
}
export interface ScoutBottomBarItemCustomEvent<T> extends CustomEvent<T> {
detail: T;
Expand Down Expand Up @@ -480,6 +494,12 @@ declare global {
prototype: HTMLScoutSwitchElement;
new (): HTMLScoutSwitchElement;
};
interface HTMLScoutTextAreaElement extends Components.ScoutTextArea, HTMLStencilElement {
}
var HTMLScoutTextAreaElement: {
prototype: HTMLScoutTextAreaElement;
new (): HTMLScoutTextAreaElement;
};
interface HTMLElementTagNameMap {
"scout-bottom-bar": HTMLScoutBottomBarElement;
"scout-bottom-bar-item": HTMLScoutBottomBarItemElement;
Expand All @@ -497,6 +517,7 @@ declare global {
"scout-select": HTMLScoutSelectElement;
"scout-stack": HTMLScoutStackElement;
"scout-switch": HTMLScoutSwitchElement;
"scout-text-area": HTMLScoutTextAreaElement;
}
}
declare namespace LocalJSX {
Expand Down Expand Up @@ -755,6 +776,20 @@ declare namespace LocalJSX {
*/
"toggled"?: boolean;
}
interface ScoutTextArea {
/**
* @default false
*/
"autofocus"?: boolean;
"disabled"?: boolean;
"form"?: string;
"label"?: string;
"maxLength"?: number;
"placeholder"?: string;
"readOnly"?: boolean;
"required"?: boolean;
"value"?: string;
}
interface IntrinsicElements {
"scout-bottom-bar": ScoutBottomBar;
"scout-bottom-bar-item": ScoutBottomBarItem;
Expand All @@ -772,6 +807,7 @@ declare namespace LocalJSX {
"scout-select": ScoutSelect;
"scout-stack": ScoutStack;
"scout-switch": ScoutSwitch;
"scout-text-area": ScoutTextArea;
}
}
export { LocalJSX as JSX };
Expand Down Expand Up @@ -808,6 +844,7 @@ declare module "@stencil/core" {
"scout-select": LocalJSX.ScoutSelect & JSXBase.HTMLAttributes<HTMLScoutSelectElement>;
"scout-stack": LocalJSX.ScoutStack & JSXBase.HTMLAttributes<HTMLScoutStackElement>;
"scout-switch": LocalJSX.ScoutSwitch & JSXBase.HTMLAttributes<HTMLScoutSwitchElement>;
"scout-text-area": LocalJSX.ScoutTextArea & JSXBase.HTMLAttributes<HTMLScoutTextAreaElement>;
}
}
}
23 changes: 23 additions & 0 deletions packages/ui-webc/src/components/text-area/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# scout-text-area

<!-- Auto Generated Below -->


## Properties

| Property | Attribute | Description | Type | Default |
| ------------- | ------------- | ----------- | --------- | ----------- |
| `autofocus` | `autofocus` | | `boolean` | `false` |
| `disabled` | `disabled` | | `boolean` | `undefined` |
| `form` | `form` | | `string` | `undefined` |
| `label` | `label` | | `string` | `undefined` |
| `maxLength` | `max-length` | | `number` | `undefined` |
| `placeholder` | `placeholder` | | `string` | `undefined` |
| `readOnly` | `read-only` | | `boolean` | `undefined` |
| `required` | `required` | | `boolean` | `undefined` |
| `value` | `value` | | `string` | `undefined` |


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
21 changes: 21 additions & 0 deletions packages/ui-webc/src/components/text-area/text-area.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
:host {
display: inline-flex;
}

.flexbox{
display: inline-flex;
flex-direction: column;
padding: 0.5rem;
}

.textarea{
resize: none;
height: var(--spacing-24);
width: var(--spacing-50);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave out the width and height and let the consumer control this as it will most likely depend on their layout. Maybe instead we can expose the rows attribute as a prop and set the default to something a bit higher, say 3?

padding: var(--spacing-2);
font: var(--type-body-base);
border: 1px solid var(--color-gray-300);
border-radius: var(--spacing-2);
background-color: var(--color-white);
color: var(--color-text-base);
}
50 changes: 50 additions & 0 deletions packages/ui-webc/src/components/text-area/text-area.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Component, h, Prop } from "@stencil/core";

@Component({
tag: "scout-text-area",
styleUrl: "text-area.css",
shadow: {
delegatesFocus: true,
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to other comment about adding support for the Field component, you'll have to disable the shadow DOM and use scoped styles for it to work:

Suggested change
shadow: {
delegatesFocus: true,
},
scoped: true,

})

export class ScoutTextArea {
@Prop() autofocus: boolean = false;

@Prop() disabled?: boolean;

@Prop() form: string;

@Prop() maxLength?: number;

@Prop() placeholder?: string;

@Prop() readOnly?: boolean;

@Prop() required?: boolean;

@Prop() value?: string;

@Prop() label?: string;

render() {
return (
<div class="flexbox">
<div>
{this.label}
</div>
<textarea
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we maybe add the name prop as well? I just realized we don't have it on any of our inputs, so I'll add it to the rest in a separate PR 😊

class="textarea"
autofocus={this.autofocus}
disabled={this.disabled}
form={this.form}
maxLength={this.maxLength}
placeholder={this.placeholder}
readOnly={this.readOnly}
required={this.required}
value={this.value}
/>
</div>
);
}
}
Loading