-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(design-land): add file tabs back to code preview and allow conte…
…nt to be hidden (#2578)
- Loading branch information
Showing
7 changed files
with
75 additions
and
18 deletions.
There are no files selected for viewing
19 changes: 18 additions & 1 deletion
19
apps/design-land/src/app/core/code-preview/component/code-preview-theme.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
@use 'sass:map'; | ||
@use 'theme' as daff-theme; | ||
|
||
|
||
@mixin code-preview-theme($theme) { | ||
$gray: daff-theme.daff-map-deep-get($theme, 'core.gray'); | ||
$base: daff-theme.daff-map-deep-get($theme, 'core.base'); | ||
$primary: map.get(daff-theme.$theme, primary); | ||
$font-color: daff-theme.daff-map-deep-get($theme, 'core.font-color'); | ||
$border: 1px solid daff-theme.daff-illuminate($base, $gray, 2); | ||
|
||
.design-land-code-preview { | ||
&__content { | ||
border: 1px solid rgba(daff-theme.daff-illuminate($base, $gray, 2), 0.6); | ||
border: $border; | ||
border-bottom: 0; | ||
} | ||
|
||
&__tab-wrapper { | ||
border-left: $border; | ||
border-right: $border; | ||
} | ||
|
||
&__tab { | ||
color: $font-color; | ||
|
||
&.selected { | ||
border-bottom: 2px solid daff-theme.daff-color($primary); | ||
} | ||
} | ||
} | ||
} |
9 changes: 6 additions & 3 deletions
9
apps/design-land/src/app/core/code-preview/component/code-preview.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<div #content class="design-land-code-preview__content"></div> | ||
<div *ngIf="example" class="design-land-code-preview__file-container"> | ||
<pre class="design-land-code-preview__code-block"><code [class]="'hljs' + ' ' +file.language" [innerHtml]="file.content"></code></pre> | ||
</div> | ||
<ng-container *ngIf="example"> | ||
<div class="design-land-code-preview__tab-wrapper"> | ||
<button class="design-land-code-preview__tab" [class.selected]="exampleFile === file" (click)="exampleFile = file" *ngFor="let file of example.files">{{ file.language }}</button> | ||
</div> | ||
<pre class="design-land-code-preview__code-block"><code [class]="'hljs' + ' ' +exampleFile.language" [innerHtml]="exampleFile.content"></code></pre> | ||
</ng-container> |
42 changes: 37 additions & 5 deletions
42
apps/design-land/src/app/core/code-preview/component/code-preview.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,49 @@ | ||
@use 'utilities' as daff; | ||
|
||
:host { | ||
$root: '.design-land-code-preview'; | ||
display: block; | ||
margin: 20px 0; | ||
margin: 1.5rem 0; | ||
|
||
&.hide-content { | ||
#{$root}__content { | ||
display: none; | ||
} | ||
|
||
#{$root}__tab-wrapper { | ||
border: none; | ||
} | ||
} | ||
|
||
} | ||
|
||
.design-land-code-preview { | ||
display: block; | ||
margin: 1.5rem 0; | ||
|
||
&__content { | ||
display: block; | ||
padding: 48px 24px; | ||
border-radius: 8px 8px 0 0; | ||
padding: 1rem; | ||
|
||
@include daff.breakpoint(mobile) { | ||
padding: 2rem; | ||
} | ||
} | ||
|
||
&__code-block { | ||
margin-top: 0; | ||
border-radius: 0 0 8px 8px; | ||
margin: 0; | ||
border-radius: 0; | ||
} | ||
|
||
&__tab { | ||
@include daff.clickable(); | ||
appearance: none; | ||
border: none; | ||
background: none; | ||
font-size: 0.875rem; | ||
line-height: 1rem; | ||
font-weight: 500; | ||
padding: 12px 16px; | ||
text-transform: uppercase; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/design-land/src/app/core/code-preview/container/example-viewer.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<design-land-code-preview [title]="title" [example]="selectedExample$ | async"></design-land-code-preview> | ||
<design-land-code-preview [title]="title" [example]="selectedExample$ | async" [hideContent]="hideContent"></design-land-code-preview> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters