Skip to content

Commit

Permalink
Merge pull request #68 from plotly/gallery-page
Browse files Browse the repository at this point in the history
Added in github links to app source code in the header for each app.
  • Loading branch information
Shammamah Hossain authored Dec 3, 2018
2 parents fb7cf17 + 318dd37 commit 7e6dc0b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 11 deletions.
Binary file added assets/GitHub-Mark-64px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/GitHub-Mark-Light-64px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions assets/general-app-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,26 @@
float: left;
padding: 10px;
padding-bottom: 0px;
transition-duration:500ms;
}

#app-page-header > a > img:hover {
filter:brightness(2.00);
}

#app-page-header h2 {
font-size: 34pt;
display: inline-block;
}

#app-page-header #gh-link > img {
height: 50px;
float:right;
margin-top: 15px;
margin-right: 10px;
transition-duration:500ms;
}

#app-page-header #gh-link > img:hover {
-webkit-filter:invert(100%);
}
34 changes: 23 additions & 11 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
)


def demoAppImgSrc(name):
def demo_app_img_src(name):
''' Returns the base-64 encoded image corresponding
to the specified app.'''
pic_fname = './tests/dash/images/pic_{}.png'.format(
name.replace('app_', '')
)
Expand All @@ -67,11 +69,14 @@ def demoAppImgSrc(name):
open('./assets/dashbio_logo.png', 'rb').read()).decode())


def demoAppName(name):
def demo_app_name(name):
''' Returns a capitalized title for the app, with "Dash"
in front.'''
return 'Dash ' + name.replace('app_', '').replace('_', ' ').title()


def demoAppDesc(name):
def demo_app_desc(name):
''' Returns the content of the description specified in the app. '''
desc = ''
try:
desc = apps[name].description()
Expand All @@ -80,13 +85,19 @@ def demoAppDesc(name):
return desc


def demoAppHeaderColors(name):
def demo_app_header_colors(name):
''' Returns the colors of the header specified in the app, if any. '''
try:
return apps[name].headerColors()
return apps[name].header_colors()
except AttributeError:
return {}


def demo_app_github_url(name):
''' Returns the link with the code for the demo app. '''
return name


@app.callback(Output("container", "children"), [Input("location", "pathname")])
def display_app(pathname):
if pathname == '/{}'.format(DASH_APP_NAME) \
Expand All @@ -99,14 +110,14 @@ def display_app(pathname):
dcc.Link(
children=[
html.Img(className='gallery-app-img',
src=demoAppImgSrc(name)),
src=demo_app_img_src(name)),
html.Div(className='gallery-app-info', children=[
html.Div(className='gallery-app-name', children=[
demoAppName(name)
demo_app_name(name)
]),
html.Div(className='gallery-app-desc', children=[
demoAppDesc(name)
]),
demo_app_desc(name)
])
])
],
href="/{}/{}".format(
Expand All @@ -126,8 +137,9 @@ def display_app(pathname):
return html.Div(id="waitfor",
children=app_page_layout(
apps[app_name].layout(),
app_title=demoAppName(app_name),
**demoAppHeaderColors(app_name)
app_title=demo_app_name(app_name),
app_github_url=demo_app_github_url(app_name),
**demo_app_header_colors(app_name)
))
else:
return """
Expand Down
17 changes: 17 additions & 0 deletions tests/dash/utils/app_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

def app_page_layout(page_layout,
app_title="Dash Bio App",
app_github_url="",
light_logo=True,
bg_color="#506784",
font_color="#F3F6FA"):
return html.Div(
Expand All @@ -27,6 +29,21 @@ def app_page_layout(page_layout,
),
html.H2(
app_title
),
html.A(
id='gh-link',
children=[
html.Img(
src='data:image/png;base64,{}'.format(
base64.b64encode(open(
'./assets/GitHub-Mark-{}64px.png'.format(
'Light-' if light_logo else ''),
'rb').read()
).decode()
)
)
],
href="http://github.com/plotly/dash-bio/blob/master/tests/dash/app_{}.py".format(app_github_url)
)
],
style={
Expand Down

0 comments on commit 7e6dc0b

Please sign in to comment.