Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kus-admin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
kus-admin
Commits
c0551e88
Commit
c0551e88
authored
Jan 25, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input bindin
parent
6c0add61
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
14 deletions
+62
-14
base.scss
src/base.scss
+2
-4
Store.js
src/core/data/store/Store.js
+15
-2
Input.jsx
src/view/cmp/field/Input.jsx
+14
-0
LabeledField.jsx
src/view/cmp/field/LabeledField.jsx
+3
-1
Switch.jsx
src/view/cmp/switch/Switch.jsx
+2
-2
Login.jsx
src/view/page/login/Login.jsx
+26
-5
No files found.
src/base.scss
View file @
c0551e88
...
...
@@ -5,6 +5,4 @@ $d-green: #006C43;
$l-green
:
#34BE5B
;
$gray
:
#a6a6a6
;
$font
:
'SF Pro Text'
,
Arial
,
sans-serif
;
b
{
color
:
pink
}
\ No newline at end of file
$font
:
'SF Pro Text'
,
Arial
,
sans-serif
;
\ No newline at end of file
src/core/data/store/Store.js
View file @
c0551e88
...
...
@@ -38,7 +38,21 @@ Store.prototype = {
this
.
on
(
key
,
wrap
);
wrap
(
this
.
get
(
key
));
return
this
;
},
bind
:
function
(
key
)
{
return
new
StoreBinding
(
this
,
key
);
}
};
const
StoreBinding
=
function
(
store
,
key
){
this
.
store
=
store
;
this
.
key
=
key
;
};
StoreBinding
.
prototype
=
{
sub
:
function
(
fn
)
{
this
.
store
.
sub
(
this
.
key
,
fn
);
},
set
:
function
(
val
)
{
this
.
store
.
set
(
this
.
key
,
val
);
}
};
Store
.
prototype
=
Object
.
assign
(
new
Observable
,
Store
.
prototype
);
\ No newline at end of file
src/view/cmp/field/Input.jsx
0 → 100644
View file @
c0551e88
export
default
D
.
declare
(
'view.cmp.field.Input'
,
(
cfg
)
=>
{
const
dom
=
<
input
class=
"labeled-field__input"
type=
{
'text'
}
{
...
cfg
}
/>;
if
(
cfg
.
bind
){
cfg
.
bind
.
sub
(
function
(
val
)
{
dom
.
value
=
val
;
});
dom
.
addEventListener
(
'input'
,
function
()
{
cfg
.
bind
.
set
(
dom
.
value
);
})
}
return
dom
;
})
\ No newline at end of file
src/view/cmp/field/LabeledField.jsx
View file @
c0551e88
import
'./LabeledField.scss'
;
import
Input
from
'./Input.jsx'
;
export
default
D
.
declare
(
'view.cmp.field.LabeledField'
,
(
cfg
)
=>
<
div
class=
"labeled-field"
>
<
label
class=
"labeled-field__label"
>
<
span
class=
"labeled-field__label-text"
>
{
cfg
.
label
}
</
span
>
<
input
class=
"labeled-field__input"
type=
{
'text'
}
/>
<
Input
class=
"labeled-field__input"
type=
{
'text'
}
{
...
cfg
}
/>
</
label
>
</
div
>
)
src/view/cmp/switch/Switch.jsx
View file @
c0551e88
export
default
D
.
declare
(
'view.cmp.Switch'
,
(
cfg
,
contentHash
)
=>
{
const
cmp
=
div
(
{
cls
:
update
=>
store
.
sub
(
cls
:
update
=>
(
cfg
.
store
||
store
)
.
sub
(
cfg
.
key
,
val
=>
update
(
D
.
cls
(
...
...
@@ -8,7 +8,7 @@ export default D.declare('view.cmp.Switch', (cfg, contentHash) => {
cfg
.
cls
,
{
'cmp-switch__filled'
:
val
in
contentHash
}
)
)
)
}
);
store
.
sub
(
cfg
.
key
,
(
val
)
=>
{
(
cfg
.
store
||
store
)
.
sub
(
cfg
.
key
,
(
val
)
=>
{
D
.
removeChildren
(
cmp
);
if
(
val
in
contentHash
)
D
.
appendChild
(
cmp
,
contentHash
[
val
]
);
...
...
src/view/page/login/Login.jsx
View file @
c0551e88
...
...
@@ -2,13 +2,34 @@ import '../../cmp/field/LabeledField.jsx';
import
Logo
from
'../../../svg/logo_vkusvill.svg'
;
import
'./loginPage.scss'
;
export
default
D
.
declare
(
'view.page.Login'
,
()
=>
<
div
className=
{
"login-page"
}
>
export
default
D
.
declare
(
'view.page.Login'
,
()
=>
{
const
loginStore
=
new
Store
({
phone
:
'7'
,
code
:
''
,
active
:
'enterPhone'
,
phoneValid
:
false
});
loginStore
.
sub
(
'phone'
,
function
(
phone
)
{
loginStore
.
set
(
'phoneValid'
,
phone
.
length
===
11
);
});
return
<
div
className=
{
"login-page"
}
>
<
div
class=
"login-page__big-logo"
>
<
Logo
width=
"660"
height=
"300"
/>
</
div
>
<
view
.
cmp
.
field
.
LabeledField
label=
{
'Login'
}
/>
<
view
.
cmp
.
field
.
LabeledField
label=
{
'Password'
}
/>
{
view
.
cmp
.
Switch
({
store
:
loginStore
,
key
:
'active'
},
{
enterPhone
:
[
<
view
.
cmp
.
field
.
LabeledField
label=
{
'Login'
}
bind=
{
loginStore
.
bind
(
'phone'
)
}
/>,
<
button
onclick=
{
()
=>
loginStore
.
set
(
'active'
,
'enterCode'
)
}
disabled=
{
_
=>
loginStore
.
equal
(
'phoneValid'
,
false
,
_
)
}
>
Ага
</
button
>
],
enterCode
:
[
<
button
onClick=
{
()
=>
loginStore
.
set
(
'active'
,
'enterPhone'
)
}
>
Взат
</
button
>,
<
view
.
cmp
.
field
.
LabeledField
label=
{
'Code'
}
/>
]
})
}
<
button
type=
{
'button'
}
onclick=
{
()
=>
store
.
set
(
'navigation.current'
,
'main'
)
}
>
To account
</
button
>
</
div
>
)
}
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment