Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
939bbf7b
Commit
939bbf7b
authored
Feb 04, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CSS] Dynamic CSS by color with kamaieu ok (need to improve the function to increase light.
parent
67902e11
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
3 deletions
+59
-3
design.py
gargantext_web/design.py
+59
-3
No files found.
gargantext_web/design.py
View file @
939bbf7b
...
...
@@ -2,11 +2,45 @@ from django.http import Http404, HttpResponse, HttpResponseRedirect
from
django.template.loader
import
get_template
from
django.template
import
Context
import
igraph
,
colorsys
,
struct
,
binascii
def
hex2rgb
(
hex_color
):
return
struct
.
unpack
(
'BBB'
,
hex_color
.
decode
(
'hex'
))
def
rgb2hex
(
rgb_color
):
return
binascii
.
hexlify
(
struct
.
pack
(
'BBB'
,
*
rgb_color
))
def
round_tuple
(
data_tuple
):
return
(
tuple
(
map
(
lambda
x
:
round
(
x
*
255
),
data_tuple
)))
def
kamaieu
(
color_name
,
number
=
18
,
order
=
None
):
'''
Order from dark to light
Order from light to dark
'''
r
,
g
,
b
=
igraph
.
color_name_to_rgb
(
color_name
)
h
,
l
,
s
=
colorsys
.
rgb_to_hls
(
r
,
g
,
b
)
colors_hls
=
[(
h
,
l
/
(
1
+
1.9
/
light
),
s
)
for
light
in
range
(
1
,
number
)]
colors_rgb
=
[
colorsys
.
hls_to_rgb
(
*
color
)
for
color
in
colors_hls
]
print
(
colors_rgb
)
colors_rgb_round
=
list
(
map
(
round_tuple
,
colors_rgb
))
print
(
colors_rgb_round
)
colors_hex
=
[
rgb2hex
(
color
)
for
color
in
colors_rgb_round
]
return
(
colors_hex
)
def
logo
(
request
):
template
=
get_template
(
'logo.svg'
)
group
=
"mines"
group
=
"cnrs"
#
group = "cnrs"
if
group
==
"cnrs"
:
color
=
"#093558"
else
:
...
...
@@ -20,7 +54,7 @@ def css(request):
template
=
get_template
(
'bootstrap.css'
)
css
=
dict
()
group
=
"mines"
group
=
"
cnrs
"
group
=
"
test
"
if
group
==
"mines"
:
css
[
'color'
]
=
'#666666'
...
...
@@ -39,7 +73,29 @@ def css(request):
css
[
'list_group'
]
=
'#f2bcbc'
css
[
'label_default'
]
=
'#888a88'
css
[
'label_primary_focus'
]
=
'#921d1d'
elif
group
==
"test"
:
list_css
=
[
'focus'
,
'navbar_inverse_background'
,
'navbar_inverse_border'
,
'hr'
,
# container background
'a'
,
# button primary
'form'
,
'help'
,
'border'
,
'button_background'
,
'text'
,
'background'
,
# background
'button_border'
,
'list_group'
,
'label_default'
,
'label_primary_focus'
,
'color'
,
# color of text
]
colors
=
kamaieu
(
'pink'
,
number
=
len
(
list_css
))
css
=
{
i
[
0
]:
'#'
+
i
[
1
]
.
decode
(
'utf-8'
)
for
i
in
zip
(
list_css
,
colors
)}
print
(
css
)
else
:
css
[
'color'
]
=
'#AA2E09'
# color of text
css
[
'background'
]
=
'#93AA00'
# background
...
...
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