Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kcodeblock): component reskin [KHCP-8975] #2100

Merged
merged 19 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
249 changes: 102 additions & 147 deletions docs/components/codeblock.md

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions docs/guide/migrating-to-version-9.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,52 @@ Kongponents styles are no longer designed to be utilized standalone, separately

#### Props

* `isSearchable` prop has been removed and replaced with `searchable`
* `isProcessing` prop has been removed and replaced with `processing`
* `isSingleLine` prop has been removed and replaced with `singleLine`

#### Structure

* `k-code-block-actions` class has been changed to `code-block-actions`
* `k-code-block-search-results` class has been changed to `code-block-search-results`
* `k-code-block-search-results-has-query` class has been changed to `code-block-search-results-has-query`
* `k-search-container` class has been changed to `search-container`
* `k-search-icon` class has been changed to `code-block-search-icon`
* `k-code-block-search-icon` `data-testid` attribute has been replaced with `code-block-search-icon`
* `k-code-block-search-input` class and `data-testid` attribute has been changed to `code-block-search-input`
* `k-code-block-search-error` class has been changed to `code-block-search-error`
* `k-is-processing-icon` class has been changed to `processing-icon`
* `k-code-block-is-processing-icon` `data-testid` attribute has been replaced with `processing-icon`
* `k-clear-query-button` and `k-clear-icon` classes changed to `clear-query-button`
* `k-code-block-clear-query-button` and `k-code-block-clear-icon` `data-testid` attributes were replaced with `clear-query-button`
* `k-search-actions` class has been changed to `code-block-search-actions`
* `k-regexp-mode-button` class has been changed to `regexp-mode-button`
* `k-code-block-regexp-mode-button` `data-testid` attribute has been replaced with `regexp-mode-button`
* `k-filter-mode-button` class has been changed to `filter-mode-button`
* `k-code-block-filter-mode-button` `data-testid` attribute has been replaced with `filter-mode-button`
* `k-previous-match-button` class has been changed to `previous-match-button`
* `k-code-block-previous-match-button` `data-testid` attribute has been replaced with `previous-match-button`
* `k-next-match-button` class has been changed to `next-match-button`
* `k-code-block-next-match-button` `data-testid` attribute has been replaced with `next-match-button`
* `k-code-block-content` class has been changed to `code-block-content`
* `k-filtered-code-block` class has been changed to `filtered-code-block`
* `k-code-block-filtered-code-block` `data-testid` attribute has been replaced with `filtered-code-block`
* `k-line-number-rows` class has been changed to `line-number-rows`
* `k-line` class has been changed to `line`
* `k-line-anchor` class has been changed to `line-anchor`
* `k-highlighted-code-block` class has been changed to `highlighted-code-block`
* `k-code-block-highlighted-code-block` `data-testid` attribute has been replaced with `highlighted-code-block`
* `is-single-line` class has been changed to `single-line`
* `k-line-number-rows` class has been changed to `line-number-rows`
* `k-line-is-match` class has been changed to `line-is-match`
* `k-line-is-highlighted-match` class has been changed to `line-is-highlighted-match`
* `k-line-anchor` class has been changed to `line-anchor`
* `k-code-block-secondary-actions` class has been changed to `code-block-secondary-actions`
* `k-code-block-copy-button` class and `data-testid` attribute has been changed to `code-block-copy-button`
* `k-matched-term` `class` has been replaced with `matched-term`

#### Props

* New `maxHeight` prop to control the `max-height` of the code block. Defaults to `none`

#### Slots
Expand Down
1 change: 1 addition & 0 deletions sandbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const sandboxAppLinks: SandboxNavigationItem[] = ([
{ name: 'KCard', to: { name: 'card' } },
{ name: 'KCatalog', to: { name: 'catalog' } },
{ name: 'KCheckbox', to: { name: 'checkbox' } },
{ name: 'KCodeBlock', to: { name: 'codeblock' } },
{ name: 'KCopy', to: { name: 'copy' } },
{ name: 'KDateTimePicker', to: { name: 'datetimepicker' } },
{ name: 'KDropdown', to: { name: 'dropdown' } },
Expand Down
219 changes: 219 additions & 0 deletions sandbox/pages/SandboxCodeBlock.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<template>
<SandboxLayout
:links="inject('app-links', [])"
title="KCodeBlock"
>
<div class="kcodeblock-sandbox">
<!-- Figma -->
<SandboxTitleComponent
is-subtitle
title="Figma"
/>
<KExternalLink href="https://www.figma.com/file/Yze0SWXl5nKjR0rFdilljK/Components?type=design&node-id=2020%3A11253&mode=dev&t=wfYkBJZ5Ry0OUS2m-1">
Figma
</KExternalLink>

<!-- Props -->
<SandboxTitleComponent
is-subtitle
title="Props"
/>
<SandboxSectionComponent
class="limited-width"
title="code & language"
>
<KCodeBlock
id="code-language-props"
:code="code"
language="json"
/>
</SandboxSectionComponent>
<SandboxSectionComponent
class="limited-width"
title="initialFilterMode & initialRegExpMode & searchable"
>
<KCodeBlock
id="filter-regex-modes-props"
:code="code"
initial-reg-exp-mode
language="json"
searchable
/>
</SandboxSectionComponent>
<SandboxSectionComponent
class="limited-width"
title="singleLine"
>
<KCodeBlock
id="single-line-prop"
:code="singleLineCode"
language="plaintext"
single-line
/>
</SandboxSectionComponent>
<SandboxSectionComponent
class="limited-width"
title="processing"
>
<KCodeBlock
id="processing-prop"
:code="code"
language="json"
processing
searchable
/>
</SandboxSectionComponent>
<SandboxSectionComponent
class="limited-width"
title="maxHeight"
>
<KCodeBlock
id="max-height-prop"
:code="code"
language="json"
max-height="200"
searchable
/>
</SandboxSectionComponent>
<SandboxSectionComponent
class="limited-width"
title="query"
>
<KCodeBlock
id="query-prop"
:code="code"
language="json"
max-height="200"
query="compilerOptions"
searchable
/>
</SandboxSectionComponent>
<SandboxSectionComponent
class="limited-width"
title="showCopyButton"
>
<KCodeBlock
id="show-copy-button-prop"
:code="code"
language="json"
searchable
:show-copy-button="false"
/>
</SandboxSectionComponent>
<SandboxSectionComponent
class="limited-width"
title="showLineNumberLinks"
>
<KCodeBlock
id="show-line-number-links-prop"
:code="code"
language="json"
searchable
show-line-number-links
/>
</SandboxSectionComponent>
<SandboxSectionComponent
class="limited-width"
title="theme"
>
<KCodeBlock
id="theme-prop"
:code="code"
initial-reg-exp-mode
language="json"
max-height="200"
processing
query="compilerOptions"
searchable
theme="dark"
/>
<KCodeBlock
id="single-line-dark-prop"
:code="singleLineCode"
language="plaintext"
single-line
theme="dark"
/>
</SandboxSectionComponent>

<!-- Slots -->
<SandboxTitleComponent
is-subtitle
title="Slots"
/>
<SandboxSectionComponent
class="limited-width"
title="secondary-actions"
>
<KCodeBlock
id="secondary-actions-slot"
:code="code"
language="json"
>
<template #secondary-actions>
<KButton>
Secondary Action
</KButton>
Comment on lines +154 to +156
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Should this use a KCodeBlockIconButton? That would help verify that using it has the right styles just by looking at the sandbox.

</template>
</KCodeBlock>
</SandboxSectionComponent>
</div>
</SandboxLayout>
</template>

<script setup lang="ts">
import { inject } from 'vue'
import SandboxTitleComponent from '../components/SandboxTitleComponent.vue'
import SandboxSectionComponent from '../components/SandboxSectionComponent.vue'

const code = `{
"compilerOptions": {
"target": "es2020",
"module": "esnext",
"moduleResolution": "node",
"allowUnreachableCode": false,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"jsx": "preserve"
},
"include": [
"./src",
"./types",
"./particularly-long-value-that-will-inadvertently-cause-scrolling-for-narrower-containers"
]
}`

const singleLineCode = `-----BEGIN CERTIFICATE-----
MIIDlDCCAn6gAwIBAgIBATALBgkqhkiG9w0BAQ0wNDEyMAkGA1UEBhMCVVMwJQYD
VQQDHh4AawBvAG4AbgBlAGMAdAAtAGQAZQBmAGEAdQBsAHQwHhcNMjMwMTAzMTg1
NDQxWhcNMzMwMTAzMTg1NDQxWjA0MTIwCQYDVQQGEwJVUzAlBgNVBAMeHgBrAG8A
bgBuAGUAYwB0AC0AZABlAGYAYQB1AGwAdDCCASIwDQYJKoZIhvcNAQEBBQADggEP
ADCCAQoCggEBAJ1dzsZKtwFniWQaxIEqrs2EH95fWQ4Jie+79jJL1unRJJu5oDnR
5ontJZhPFSDdGZ1ZXhjQXIzaUk3BoFn7Zel7X25hzUdlKHoOTPf/KA7+isdvS89j
nGoC5vHtXQmgzNFRdCjeKDOmfa/Arff7+41SNTT+DNitZun+V3diePoatotOT3tv
puNqc5EjHLEGOdBwxSkO7qCvzsqOcFyBshT8AzFKU8aapErlILOIJKJIYHoAkS/A
cUfm/MNNMzPBBI3p1jZKXnWCwXMWUi8jZvsALYwn8E65GE07jW2O+n9hWzC43yTu
DYW0U8vcoTsdPmsZByIFDfERaxavQiEuhf0CAwEAAaOBtDCBsTASBgNVHRMBAf8E
CDAGAQH/AgEDMAsGA1UdDwQEAwIABjAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYB
BQUHAwIwFwYJKwYBBAGCNxQCBAoMCGNlcnRUeXBlMCMGCSsGAQQBgjcVAgQWBBQB
AQEBAQEBAQEBAQEBAQEBAQEBATAcBgkrBgEEAYI3FQcEDzANBgUpAQEBAQIBCgIB
FDATBgkrBgEEAYI3FQEEBgIEABQACjALBgkqhkiG9w0BAQ0DggEBABGVFc6DTlx7
SuKgT3OhQS94VyECnJjyk2eR6/MaZYvgw0Iz8nOyg7xTtj7DKl/uyHdJWwYn5R70
+YGF7GGbkk6rkRuHEVT+dhyYwO9fKzBZkLNnzdp900VSmTubx4j6WN0+gmQS0dLW
uyBQdUiKvE/ZTjWHUAIYb3244VRRHBRLs3s40f2mJjBZ3Zm6XUxGtsnYudWOh4cv
nYKRWqogwSBtKPYAe115DLDULxe86Cu5neYTt5/kU7VjnLxhOhguWTIrGMSV0Jle
Rl1IG8evLu2zWxN3wb451/Kf5lRFLUjfjuLD8tHMlpwVIxoHct9GuKV4W14cf2Q/
cWMCwpGsAAE=
-----END CERTIFICATE-----`
</script>

<style lang="scss" scoped>
.limited-width {
max-width: 90%;
}
</style>
6 changes: 6 additions & 0 deletions sandbox/router/sandbox-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ const componentRoutes: RouteRecordRaw[] = [
meta: { title: 'Checkbox Sandbox' },
component: () => import('../pages/SandboxCheckbox.vue'),
},
{
path: '/codeblock',
name: 'codeblock',
meta: { title: 'Code Block Sandbox' },
component: () => import('../pages/SandboxCodeBlock.vue'),
},
{
path: '/copy',
name: 'copy',
Expand Down
Loading