Skip to content

Commit

Permalink
refactor: Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
unlight committed May 1, 2021
1 parent 0d373e1 commit d4a9d48
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@
<label for="name" class="is-float-label bg-white text-gray-700">Name</label>
</div>
<div class="has-float-label">
<label for="Login" class="is-float-label bg-white text-gray-700">Login</label>
<label for="Login" class="is-float-label bg-white text-gray-700"
>Login (Always visible)</label
>
<input
type="text"
id="Login"
autocomplete="off"
placeholder="Login"
class="control-with-float-label outline-none focus:shadow-outline border w-full px-1 text-base"
value="Login"
value=""
/>
</div>
<div class="has-float-label">
Expand Down
22 changes: 12 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import { DeepPartial } from 'simplytyped';

const defaultConfig = {
control: 'pt-2 pb-1',
label: {
...toObject('leading-none text-xs px-1'),
top: 'calc(-0.125rem * 3)',
left: '0.25rem',
},
};

export type Options = {
/**
* Custom styles for container.
Expand All @@ -27,7 +18,18 @@ export type Options = {
module.exports = floatLabelFactory;

export default function floatLabelFactory(options?: Options) {
const config: Options = { ...defaultConfig, ...options };
const config: Options = Object.assign(
{},
{
control: 'py-1', // after pt-2
label: {
...toObject('leading-none text-xs px-1'),
top: 'calc(-0.125rem * 3)',
left: '0.25rem',
},
},
options,
);

return ({ addComponents }) => {
const container = config.container ? toObject(config.container) : {};
Expand Down

0 comments on commit d4a9d48

Please sign in to comment.