Skip to content

Commit

Permalink
refactor(theme): improve active style for previewer
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript committed Aug 20, 2020
1 parent 074a080 commit 6de385c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
10 changes: 5 additions & 5 deletions packages/theme-default/src/builtins/Previewer.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
}

&-target {
border-color: #3d62d2;
border-color: fade(@c-primary, 50%);
box-shadow: 0 0 0 5px fade(@c-primary, 5%);
}

&-desc {
Expand All @@ -32,19 +33,18 @@
margin-bottom: 0;
}

&[title] {
&[data-title] {
position: relative;
padding-top: 1.2em;
pointer-events: none;

&::before {
content: attr(title);
> a:first-child {
position: absolute;
top: 0;
left: 1em;
margin-left: -4px;
padding: 0 4px;
color: @c-heading;
font-size: inherit;
font-weight: 500;
background-color: #fff;
transform: translateY(-50%);
Expand Down
19 changes: 10 additions & 9 deletions packages/theme-default/src/builtins/Previewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
useCopy,
useLocaleProps,
Link,
AnchorLink,
IPreviewerComponentProps,
} from 'dumi/theme';
import SourceCode from './SourceCode';
Expand Down Expand Up @@ -79,15 +80,15 @@ const Previewer: React.FC<IPreviewerProps> = oProps => {
>
{props.children}
</div>
<div
className="__dumi-default-previewer-desc"
onClick={() => {
history.push(`#${props.identifier}`);
}}
title={props.title}
// eslint-disable-next-line
dangerouslySetInnerHTML={{ __html: props.description }}
/>
<div className="__dumi-default-previewer-desc" data-title={props.title}>
{props.title && <AnchorLink to={`#${props.identifier}`}>{props.title}</AnchorLink>}
{props.description && (
<div
// eslint-disable-next-line
dangerouslySetInnerHTML={{ __html: props.description }}
/>
)}
</div>
<div className="__dumi-default-previewer-actions">
{openCSB && (
<button
Expand Down
4 changes: 2 additions & 2 deletions packages/theme-default/src/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe('default theme', () => {
}}
dependencies={{}}
>
<>demo-1</>
<>demo-1 Content</>
</Previewer>
<Previewer
title="demo-2"
Expand All @@ -212,7 +212,7 @@ describe('default theme', () => {
}}
dependencies={{}}
>
<>demo-2</>
<>demo-2 Content</>
</Previewer>
</>
</Layout>
Expand Down

0 comments on commit 6de385c

Please sign in to comment.