Skip to content

Commit

Permalink
Add AssistedInput component.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Apr 20, 2017
1 parent 9c37e6c commit b8f52ff
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ui_framework/components/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
*/
@mixin formControlBase {
appearance: none;
padding: 3px 12px 4px;
padding: $formControlPadding;
font-size: $globalFontSize;
font-weight: 400;
line-height: $globalLineHeight;
Expand Down
4 changes: 4 additions & 0 deletions ui_framework/components/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ $toolBarHeight: 50px;
$toolBarPadding: 10px;
$toolBarSectionSpacing: 50px;
$toolBarItsemSpacing: 10px;

// Form
$formControlPaddingSides: 12px;
$formControlPadding: 3px $formControlPaddingSides 4px;
17 changes: 17 additions & 0 deletions ui_framework/components/form/_assisted_input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* 1. Set inline-block so this wrapper shrinks to fit the input.
*/
.kuiAssistedInput {
display: inline-block; /* 1 */
position: relative;
}

/**
* 1. Vertically center the assistance, regardless of its height.
*/
.kuiAssistedInput__assistance {
position: absolute;
right: $formControlPaddingSides;
top: 50%; /* 1 */
transform: translateY(-50%); /* 1 */
}
1 change: 1 addition & 0 deletions ui_framework/components/form/_index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import "assisted_input";
@import "check_box";
@import "search_input";
@import "select";
Expand Down
20 changes: 20 additions & 0 deletions ui_framework/dist/ui_framework.css
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,26 @@ body {
line-height: 1.5;
color: #9fa3a7; }

/**
* 1. Set inline-block so this wrapper shrinks to fit the input.
*/
.kuiAssistedInput {
display: inline-block;
/* 1 */
position: relative; }

/**
* 1. Vertically center the assistance, regardless of its height.
*/
.kuiAssistedInput__assistance {
position: absolute;
right: 12px;
top: 50%;
/* 1 */
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
/* 1 */ }

/**
* 1. Deliberately disable only webkit appearance. If we disable it in Firefox, we get a really
* ugly default appearance which we can't customize, so our best option is to give Firefox
Expand Down
14 changes: 14 additions & 0 deletions ui_framework/doc_site/src/views/form/assisted_input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="kuiAssistedInput">
<input
style="width: 300px; padding-right: 5.5em"
type="text"
class="kuiTextInput"
placeholder="Enter API command"
>

<div class="kuiAssistedInput__assistance">
<p class="kuiText">
<a class="kuiLink" href="#">API docs</a>
</p>
</div>
</div>
26 changes: 26 additions & 0 deletions ui_framework/doc_site/src/views/form/form_example.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import {
GuideCode,
GuideDemo,
GuidePage,
GuideSection,
Expand All @@ -9,6 +10,7 @@ import {
} from '../../components';

const textInputHtml = require('./text_input.html');
const assistedInputHtml = require('./assisted_input.html');
const searchInputHtml = require('./search_input.html');
const staticInputHtml = require('./static_input.html');
const textAreaHtml = require('./text_area.html');
Expand All @@ -35,6 +37,30 @@ export default props => (
/>
</GuideSection>

<GuideSection
title="AssistedInput"
source={[{
type: GuideSectionTypes.HTML,
code: assistedInputHtml,
}]}
>
<GuideText>
<strong>Note:</strong> You have to specify right-side padding using a custom class or
inline style to keep the input text from overlapping with the assistance content.
Use <GuideCode>em</GuideCode> units for this padding so that it scales appropriately if the
user changes their root font-size.
</GuideText>

<GuideDemo
html={assistedInputHtml}
/>

<GuideDemo
html={assistedInputHtml}
isDarkTheme={true}
/>
</GuideSection>

<GuideSection
title="SearchInput"
source={[{
Expand Down

0 comments on commit b8f52ff

Please sign in to comment.