Skip to content

Commit

Permalink
Show file name in header
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed Feb 8, 2019
1 parent c4e5b7a commit b98a288
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/header.tsx
Expand Up @@ -17,7 +17,9 @@ const app = ({ props }) => (
)
const lazy = (func: () => void): VoidFunction => () => setTimeout(func, 16)

export const Header: ConnectableChild = ({
export const Header: ConnectableChild<'bufferChanged' | 'fileName'> = ({
bufferChanged,
fileName,
newCommand,
openCommand,
saveCommand,
Expand All @@ -37,7 +39,19 @@ export const Header: ConnectableChild = ({
</DropdownItem>
</DropdownMenu>
</Dropdown>
<div
class={[
style.file,
bufferChanged && style.fileChanged,
fileName ? '' : style.fileUntitled,
]
.filter(c => c)
.join(' ')}
>
<span class={style.fileName}>{fileName || '(untitled)'}</span>
<span class={style.fileIndicator}>*</span>
</div>
</header>
)

export default connectBufferActions()(Header)
export default connectBufferActions('bufferChanged', 'fileName')(Header)
3 changes: 3 additions & 0 deletions src/components/style/app.module.scss
@@ -1,4 +1,7 @@
.app {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif,
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
position: relative;
width: 100%;
height: 100%;
Expand Down
26 changes: 26 additions & 0 deletions src/components/style/header.module.scss
Expand Up @@ -18,3 +18,29 @@
background-repeat: no-repeat;
background-position: center;
}

.file {
display: flex;
justify-content: center;
flex: 1;
line-height: 50px;
text-align: center;

&-indicator {
color: #d10202;
font-size: smaller;
padding: 0 0 0 0.25em;
vertical-align: super;
visibility: hidden;
}

&-untitled {
color: #ccc;
}

&-changed {
.file-indicator {
visibility: visible;
}
}
}
2 changes: 2 additions & 0 deletions src/components/style/marp.module.scss
Expand Up @@ -6,6 +6,8 @@
}

&-slide-container {
all: initial;

> svg {
display: block;
transform: translateZ(0); // rendering hack
Expand Down
1 change: 1 addition & 0 deletions style/index.scss
Expand Up @@ -8,6 +8,7 @@ body {
body {
margin: 0;
padding: 0;
overflow: hidden;
}

#marp {
Expand Down

0 comments on commit b98a288

Please sign in to comment.