Skip to content

Commit

Permalink
Form
Browse files Browse the repository at this point in the history
  • Loading branch information
dorin-musteata committed Sep 6, 2020
1 parent 3ce4704 commit 334ce09
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 56 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"typescript": "^3.9.3"
},
"dependencies": {
"@qtagon/typhon-ui": "^1.6.0",
"@qtagon/typhon-ui": "^1.7.2",
"node-sass": "^4.14.1",
"sirv-cli": "^1.0.0"
}
Expand Down
10 changes: 8 additions & 2 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import notification from './examples/notification';
import search from './examples/search';
import tabs from './examples/tabs';
import form from './examples/form';
// Index examples
const examples = {
Expand All @@ -26,11 +27,15 @@
notification,
search,
tabs,
form
};
// Setup UI
let dynamic = new Typhon('main').setColumn('menu').setColumn('content');
const menu_items = [
{
title: 'Form',
},
{
title: 'Action',
},
Expand Down Expand Up @@ -60,7 +65,7 @@
},
{
title: 'Tabs',
},
}
];
/**
Expand Down Expand Up @@ -100,13 +105,14 @@
if (!detail?.parameters) return;
dynamic.onContainer('content').clear(current);
dynamic.onContainer('content').clear('subject');
dynamic.clear('modal');
dynamic = dynamic;
const component = detail?.parameters?.title || 'action';
const name = component.toLowerCase();
current = name;
examples[`${name}`](content_container);
examples[`${name}`](content_container, dynamic);
dynamic = dynamic;
};
</script>
Expand Down
96 changes: 96 additions & 0 deletions src/core/components/Form.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<script lang="ts">
import type { Action, Input } from '@qtagon/typhon-ui';
import type { Event } from '@qtagon/typhon-ui/lib/core';
import { ALIGNMENT } from '@qtagon/typhon-ui';
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
/**
* Components
*/
import caction from './Action.svelte';
const components = {
action: caction,
};
/**
* Props
*/
export let title: string = '';
export let subtitle: string = '';
export let inputs: Array<Input> = [];
/**
* Functions
*/
const emit = (name, parameters) => {
if (name) dispatch(name, parameters);
return;
};
</script>

<style type="text/scss">
@import './scss/fonts.scss';
@import './scss/alignment.scss';
.subtitle {
margin: 0.625rem 0 0 0;
}
.headline {
margin: 0 0 3.75rem 0;
}
label {
text-transform: uppercase;
}
input {
outline: none;
border: none;
margin: 0;
color: #1e1f20;
width: 100%;
height: 100%;
padding: 1.188rem;
border: 0.063rem solid #e5e5e5;
border-radius: 0.75rem;
margin: 0.625rem 0 0 0;
&:not(:last-child) {
margin: 0.625rem 0 1.25rem 0;
}
&::placeholder {
color: #4c526d;
opacity: 1;
}
&:-ms-input-placeholder {
color: #4c526d;
}
&::-ms-input-placeholder {
color: #4c526d;
}
}
</style>

<div class={`form`}>
<div class="headline">
<div class="h2 title">{title}</div>
<div class="display subtitle">{subtitle}</div>
</div>
<form>
{#each inputs as input}
<label for={input.identifier} class="label">{input.title}</label>
<input
name={input.title.toLowerCase()}
type="text"
id={input.identifier}
placeholder={input.title}
class="display" />
{/each}
</form>
</div>
6 changes: 1 addition & 5 deletions src/core/components/Message.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@
/**
* Properties
*/
export let identifier: string = '';
export let type: string = '';
export let title: string = '';
export let classified: string = '';
export let alignment: ALIGNMENT = ALIGNMENT.NONE;
export let position: POSITION = POSITION.NONE;
export let size: SIZE = SIZE.NONE;
export let style: string = '';
export let placeholder: boolean = false;
/**
*
Expand Down Expand Up @@ -58,7 +54,7 @@
}
</style>

<div class={`message ${alignment} ${position} ${classified}`}>
<div class={`message ${alignment} ${position} ${classified}`} style={style}>
{#if icon}
<div class="icon">
<svelte:component this={components.icon} {...icon} />
Expand Down
2 changes: 2 additions & 0 deletions src/core/components/Typhon/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import Message from '../Message.svelte';
import Modal from '../Modal.svelte';
import Scroller from '../Scroller.svelte';
import Form from '../Form.svelte';
const components = {
media: Media,
card: Card,
Expand All @@ -33,6 +34,7 @@
message: Message,
modal: Modal,
button: Button,
form: Form
};
/**
Expand Down
7 changes: 7 additions & 0 deletions src/core/components/scss/fonts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ h3 {
color: #4c526d;
}

.label {
font-style: normal;
font-weight: bold;
font-size: 0.75rem;
line-height: 1.25rem;
}

.display {
font-style: normal;
font-weight: 500;
Expand Down
23 changes: 23 additions & 0 deletions src/examples/form.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { SIZE } from '@qtagon/typhon-ui';

const setup = (container: any) => {
container.setSubject('Form').setClassified('h1');

/**
* Example 1
*/
container
.setSubject('Simple')
.setClassified('h3')
.setStyle('padding: 2rem 0;');

const form_e1 = container.setForm(
'Create an account',
'Signup to continue',
);
form_e1.setInput('Name');
form_e1.setInput('Email');
form_e1.setInput('Password');
};

export default setup;
49 changes: 5 additions & 44 deletions src/examples/modal.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,10 @@
import { Typhon, SIZE, ALIGNMENT, POSITION } from '@qtagon/typhon-ui';

const setup = (container: any) => {
const setup = (container: any, dynamic: any) => {
container.setSubject('Modal').setClassified('h1');

container.setSubject('Modal').setClassified('h1');

/**
* Example 1
*/
container
.setSubject('With actions & buttons')
.setClassified('h3')
.setStyle('padding: 2rem 0;');

const notificaiton_e1 = container.setNotification('John', 'Doe');

notificaiton_e1.setImage(
'https://images.pexels.com/photos/3081752/pexels-photo-3081752.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260',
SIZE.EXTRA_SMALL_X2
);

notificaiton_e1.setAction().setIcon('addUser');
notificaiton_e1.setButton('Accept').setClassified('success').setIcon('check');
notificaiton_e1.setButton('Deny').setClassified('dark').setIcon('close');

/**
* Example 2
*/
container
.setSubject('With indicator')
.setClassified('h3')
.setStyle('padding: 2rem 0;');

const notificaiton_e2 = container.setNotification(
'John',
'Wants to add you as a friend'
);

notificaiton_e2.setImage(
'https://images.pexels.com/photos/4233783/pexels-photo-4233783.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260',
SIZE.EXTRA_SMALL_X2
);

notificaiton_e2.setButton('Accept').setClassified('success').setIcon('check');
notificaiton_e2.setButton('Deny').setClassified('dark').setIcon('close');

notificaiton_e2.setIndicator();
const modal = dynamic.setModal('Lorem', 'Ipsum');
modal.setButton('Deny').setClassified('transparent bordered');
modal.setButton('Accept');
};
export default setup;
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.11.tgz#aeb16f50649a91af79dbe36574b66d0f9e4d9f71"
integrity sha512-3NsZsJIA/22P3QUyrEDNA2D133H4j224twJrdipXN38dpnIOzAbUDtOwkcJ5pXmn75w7LSQDjA4tO9dm1XlqlA==

"@qtagon/typhon-ui@^1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@qtagon/typhon-ui/-/typhon-ui-1.6.0.tgz#59f9d0ce4377028dceff7a1ed4151c181adf267f"
integrity sha512-Zl7v2zum0J7JQm//wvBwZi2xCH9NEPcy/UT82QG0Sg/MXK3zFmdIMsBbfZhd49NGvbquZa4wpwDvqW6W7GwBeQ==
"@qtagon/typhon-ui@^1.7.2":
version "1.7.2"
resolved "https://registry.yarnpkg.com/@qtagon/typhon-ui/-/typhon-ui-1.7.2.tgz#ed5f10e0c1185b829bf51b3741a96bde126ebf87"
integrity sha512-H48HpWqBxPtqy/USmnKq/uMNML6PJgLjynJ1A6leaAI3VglNyQK3EopweSFgWEEEzgJRXR2hmEh34B4yaipKcw==

"@rollup/plugin-commonjs@^14.0.0":
version "14.0.0"
Expand Down

0 comments on commit 334ce09

Please sign in to comment.