Skip to content

Commit

Permalink
Merge branch 'main' into datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd authored Nov 19, 2024
2 parents 34c2529 + 9ddf973 commit 5c4061b
Show file tree
Hide file tree
Showing 22 changed files with 285 additions and 8,921 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ module.exports = {
'vue/no-template-shadow': 'off',
'unused-imports/no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'warn'
'no-console': 'warn'
}
}
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@


# [4.6.0](https://github.com/globalbrain/sefirot/compare/v4.5.0...v4.6.0) (2024-10-08)


### Features

* **content:** add h3 styles ([#560](https://github.com/globalbrain/sefirot/issues/560)) ([7347089](https://github.com/globalbrain/sefirot/commit/7347089ecd132db9e19616a0cdf06ec909a9437f))

# [4.5.0](https://github.com/globalbrain/sefirot/compare/v4.4.2...v4.5.0) (2024-10-08)


### Bug Fixes

* **alert:** use `:deep` instead of `:slotted` to style elements ([#557](https://github.com/globalbrain/sefirot/issues/557)) ([edfc823](https://github.com/globalbrain/sefirot/commit/edfc823a11ffa116efb4499ee889f800ea6b836d))
* remove lock on ofetch ([3ad5a7d](https://github.com/globalbrain/sefirot/commit/3ad5a7d324c05e347c5ab21a4ae220c5dee42e72))


### Features

* **button:** adjust colors for disabled buttons ([#559](https://github.com/globalbrain/sefirot/issues/559)) ([4effab5](https://github.com/globalbrain/sefirot/commit/4effab529d78dfed0f1a2d795474b2d566dc0e91))
* **style:** set font antialias ([#558](https://github.com/globalbrain/sefirot/issues/558)) ([0fe3f7f](https://github.com/globalbrain/sefirot/commit/0fe3f7fc4a40630cb3b71e832a2510f175115662))

## [4.4.2](https://github.com/globalbrain/sefirot/compare/v4.4.1...v4.4.2) (2024-09-27)


### Bug Fixes

* **desc-text:** properly patch linkify-it ([e035e7f](https://github.com/globalbrain/sefirot/commit/e035e7f90d0a7d02f73e6ef878515a7f8d423511))

## [4.4.1](https://github.com/globalbrain/sefirot/compare/v4.4.0...v4.4.1) (2024-09-26)


### Bug Fixes

* **desc-text:** handle fuzzy email detection with non-ascii symbols ([453f8ba](https://github.com/globalbrain/sefirot/commit/453f8ba4faf53b4b1731b0834fb6730ddc12bbed))

# [4.4.0](https://github.com/globalbrain/sefirot/compare/v4.3.2...v4.4.0) (2024-09-25)


### Features

* **desc-text:** add linkify option ([#555](https://github.com/globalbrain/sefirot/issues/555)) ([#556](https://github.com/globalbrain/sefirot/issues/556)) ([2cd0eef](https://github.com/globalbrain/sefirot/commit/2cd0eef5fdb2373eae234dfd97394268e84202e2))

## [4.3.2](https://github.com/globalbrain/sefirot/compare/v4.3.1...v4.3.2) (2024-09-19)


Expand Down
32 changes: 30 additions & 2 deletions config/vite.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,39 @@
*/

import { fileURLToPath } from 'node:url'
import MagicString from 'magic-string'
import icons from 'unplugin-icons/vite'
import { mergeConfig } from 'vite'

/** @type {import('vite').UserConfig} */
export const baseConfig = {
plugins: [icons({ scale: 1 })],
plugins: [
icons({ scale: 1 }),
{
enforce: 'pre',
name: 'sefirot:patch-linkify-it',
transform(code, id) {
if (id.includes('linkify-it/lib/re.mjs')) {
const s = new MagicString(code)

const search = 'const text_separators = \'[><\\uff5c]\''
const replace = 'const text_separators = \'[><\\uff00-\\uffef]\''

const index = code.indexOf(search)
if (index !== -1) {
s.overwrite(index, index + search.length, replace)
}

return { code: s.toString(), map: s.generateMap({ source: id }) }
}
}
}
],

resolve: {
alias: { 'sefirot/': fileURLToPath(new URL('../lib/', import.meta.url)) },
alias: {
'sefirot/': fileURLToPath(new URL('../lib/', import.meta.url))
},

dedupe: [
'@sentry/browser',
Expand Down Expand Up @@ -55,6 +79,10 @@ export const baseConfig = {
'dayjs/plugin/relativeTime',
'dayjs/plugin/timezone',
'dayjs/plugin/utc',
'markdown-it > argparse',
'markdown-it > entities'
],
exclude: [
'markdown-it'
]
}
Expand Down
8 changes: 6 additions & 2 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ export default defineConfig({
},

themeConfig: {
outline: [2, 3],

editLink: {
pattern: 'https://github.com/globalbrain/sefirot/edit/main/docs/:path'
},

nav: [
{ text: 'Playground', link: `https://${getStoryHost()}` },
],

outline: [2, 3],

search: {
provider: 'local'
},
Expand Down
20 changes: 10 additions & 10 deletions docs/components/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,9 @@ The component has several different styles based on its type and color combinati
--button-fill-info-active-border-color: var(--c-border-info-3);
--button-fill-info-active-text-color: var(--c-white-1);
--button-fill-info-active-bg-color: var(--c-bg-info-3);
--button-fill-info-disabled-border-color: var(--c-border-info-1);
--button-fill-info-disabled-text-color: var(--c-white-a3);
--button-fill-info-disabled-content-color: var(--c-white-a3);
--button-fill-info-disabled-border-color: var(--c-blue-9);
--button-fill-info-disabled-text-color: var(--c-white-a2);
--button-fill-info-disabled-content-color: var(--c-white-a2);
--button-fill-info-disabled-bg-color: var(--c-info-bg-dark);

--button-fill-success-border-color: var(--c-border-success-1);
Expand All @@ -512,9 +512,9 @@ The component has several different styles based on its type and color combinati
--button-fill-success-active-border-color: var(--c-border-success-3);
--button-fill-success-active-text-color: var(--c-white);
--button-fill-success-active-bg-color: var(--c-bg-success-3);
--button-fill-success-disabled-border-color: var(--c-border-success-1);
--button-fill-success-disabled-text-color: var(--c-white-a3);
--button-fill-success-disabled-content-color: var(--c-white-a3);
--button-fill-success-disabled-border-color: var(--c-green-9);
--button-fill-success-disabled-text-color: var(--c-white-a2);
--button-fill-success-disabled-content-color: var(--c-white-a2);
--button-fill-success-disabled-bg-color: var(--c-success-bg-dark);

--button-fill-warning-border-color: var(--c-border-mute-1);
Expand All @@ -529,8 +529,8 @@ The component has several different styles based on its type and color combinati
--button-fill-warning-active-text-color: var(--c-white);
--button-fill-warning-active-bg-color: var(--c-bg-warning-2);
--button-fill-warning-disabled-border-color: var(--c-border-mute-1);
--button-fill-warning-disabled-text-color: var(--c-text-warning-3);
--button-fill-warning-disabled-content-color: var(--c-text-warning-3);
--button-fill-warning-disabled-text-color: var(--c-text-warning-2);
--button-fill-warning-disabled-content-color: var(--c-text-warning-2);
--button-fill-warning-disabled-bg-color: var(--c-bg-mute-1);

--button-fill-danger-border-color: var(--c-border-mute-1);
Expand All @@ -545,8 +545,8 @@ The component has several different styles based on its type and color combinati
--button-fill-danger-active-text-color: var(--c-white);
--button-fill-danger-active-bg-color: var(--c-bg-danger-2);
--button-fill-danger-disabled-border-color: var(--c-border-mute-1);
--button-fill-danger-disabled-text-color: var(--c-text-danger-3);
--button-fill-danger-disabled-content-color: var(--c-text-danger-3);
--button-fill-danger-disabled-text-color: var(--c-text-danger-2);
--button-fill-danger-disabled-content-color: var(--c-text-danger-2);
--button-fill-danger-disabled-bg-color: var(--c-bg-mute-1);

--button-outline-default-border-color: var(--c-border-mute-1);
Expand Down
14 changes: 14 additions & 0 deletions docs/components/desc.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,20 @@ You may also use `:pre-wrap` to preserve line breaks in the text. This is especi
</SDesc>
```

By specifying `:linkify`, the component will automatically convert URLs and email addresses in the text into clickable links. It will not convert any Markdown syntax or raw HTML tags. Note that this feature only works when passing in text as a prop through `:value`.

```vue-html
<SDesc cols="2" gap="24">
<SDescItem span="1">
<SDescLabel value="About" />
<SDescText
linkify
value="Clickable link: https://example.com"
/>
</SDescItem>
</SDesc>
```

## Number value

Use `<SDescNumber>` which is a specialized version of `<SDescText>` that is tailored to display numbers. It provides additional styling and formatting options that are not available in `<SDescText>`.
Expand Down
4 changes: 2 additions & 2 deletions lib/components/SAlert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ withDefaults(defineProps<{
gap: 16px;
}
.content :slotted(p) {
.content :deep(p) {
margin: 0;
max-width: 65ch;
line-height: 24px;
font-size: 14px;
}
.content :slotted(a) {
.content :deep(a) {
font-weight: 500;
text-decoration: underline;
transition: color 0.25s;
Expand Down
25 changes: 18 additions & 7 deletions lib/components/SContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
.SContent :deep(h1),
.SContent :deep(.h1) {
margin: 0;
padding: 0;
max-width: 640px;
line-height: 40px;
font-size: 32px;
Expand All @@ -23,16 +24,26 @@
.SContent :deep(h2),
.SContent :deep(.h2) {
border-top: 0;
margin: 0;
padding: 0;
max-width: 640px;
line-height: 28px;
line-height: 32px;
font-size: 20px;
font-weight: 500;
color: var(--c-text-1);
}
.SContent :deep(h3),
.SContent :deep(.h3) {
margin: 0;
padding: 0;
max-width: 640px;
line-height: 24px;
font-size: 16px;
font-weight: 500;
color: var(--c-text-1);
}
.SContent :deep(p) {
margin: 0;
max-width: 640px;
Expand Down Expand Up @@ -79,12 +90,12 @@
.SContent :deep(ul > li::before) {
position: absolute;
top: 8px;
top: 9px;
left: 2px;
width: 8px;
height: 8px;
width: 6px;
height: 6px;
border-radius: 50%;
background-color: var(--c-text-3);
background-color: var(--c-text-1);
content: "";
}
Expand All @@ -95,7 +106,7 @@
.SContent :deep(ol > li::before) {
margin-right: 3px;
margin-left: -20px;
color: var(--c-text-2);
color: var(--c-text-1);
font-feature-settings: "tnum";
content: counter(s-medium-counter)". ";
}
Expand Down
19 changes: 15 additions & 4 deletions lib/components/SDescText.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { useLinkifyIt } from 'sefirot/composables/Markdown'
import { computed } from 'vue'
import { useHasSlotContent } from '../composables/Utils'
import SDescEmpty from './SDescEmpty.vue'
Expand All @@ -7,6 +8,7 @@ const props = defineProps<{
value?: string | null
lineClamp?: string | number
preWrap?: boolean
linkify?: boolean
}>()
const classes = computed(() => [
Expand All @@ -17,14 +19,23 @@ const classes = computed(() => [
const hasSlot = useHasSlotContent()
const lineClamp = computed(() => props.lineClamp ?? 'none')
const linkifyIt = useLinkifyIt()
const _value = computed(() => {
if (props.linkify) {
return linkifyIt(props.value ?? '')
}
return props.value
})
</script>

<template>
<div v-if="hasSlot || value" class="SDescText" :class="classes">
<div class="value">
<slot v-if="hasSlot" />
<template v-else>{{ value }}</template>
<div v-if="hasSlot || _value" class="SDescText" :class="classes">
<div class="value" v-if="hasSlot">
<slot />
</div>
<div class="value" v-else v-html="_value" />
</div>
<SDescEmpty v-else />
</template>
Expand Down
14 changes: 14 additions & 0 deletions lib/composables/Markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ export function useMarkdown(options: UseMarkdownOptions = {}): UseMarkdown {
}
}

export function useLinkifyIt() {
const md = new MarkdownIt('zero', { linkify: true })
md.enable('linkify')

md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
const token = tokens[idx]
token.attrSet('target', '_blank')
token.attrSet('rel', 'noreferrer')
return self.renderToken(tokens, idx, options)
}

return (source: string) => md.renderInline(source)
}

export interface UseLink {
addListeners(): void
removeListeners(): void
Expand Down
3 changes: 3 additions & 0 deletions lib/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ body {
font-weight: 400;
color: var(--c-text-1);
background-color: var(--c-bg-elv-1);
font-synthesis: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

blockquote,
Expand Down
20 changes: 10 additions & 10 deletions lib/styles/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,9 @@
--button-fill-info-active-border-color: var(--c-border-info-3);
--button-fill-info-active-text-color: var(--c-white-1);
--button-fill-info-active-bg-color: var(--c-bg-info-3);
--button-fill-info-disabled-border-color: var(--c-border-info-1);
--button-fill-info-disabled-text-color: var(--c-white-a3);
--button-fill-info-disabled-content-color: var(--c-white-a3);
--button-fill-info-disabled-border-color: var(--c-blue-9);
--button-fill-info-disabled-text-color: var(--c-white-a2);
--button-fill-info-disabled-content-color: var(--c-white-a2);
--button-fill-info-disabled-bg-color: var(--c-blue-8);

--button-fill-success-border-color: var(--c-border-success-1);
Expand All @@ -523,9 +523,9 @@
--button-fill-success-active-border-color: var(--c-border-success-3);
--button-fill-success-active-text-color: var(--c-white);
--button-fill-success-active-bg-color: var(--c-bg-success-3);
--button-fill-success-disabled-border-color: var(--c-border-success-1);
--button-fill-success-disabled-text-color: var(--c-white-a3);
--button-fill-success-disabled-content-color: var(--c-white-a3);
--button-fill-success-disabled-border-color: var(--c-green-9);
--button-fill-success-disabled-text-color: var(--c-white-a2);
--button-fill-success-disabled-content-color: var(--c-white-a2);
--button-fill-success-disabled-bg-color: var(--c-green-8);

--button-fill-warning-border-color: var(--c-border-mute-1);
Expand All @@ -540,8 +540,8 @@
--button-fill-warning-active-text-color: var(--c-white);
--button-fill-warning-active-bg-color: var(--c-bg-warning-2);
--button-fill-warning-disabled-border-color: var(--c-border-mute-1);
--button-fill-warning-disabled-text-color: var(--c-text-warning-3);
--button-fill-warning-disabled-content-color: var(--c-text-warning-3);
--button-fill-warning-disabled-text-color: var(--c-text-warning-2);
--button-fill-warning-disabled-content-color: var(--c-text-warning-2);
--button-fill-warning-disabled-bg-color: var(--c-bg-mute-1);

--button-fill-danger-border-color: var(--c-border-mute-1);
Expand All @@ -556,8 +556,8 @@
--button-fill-danger-active-text-color: var(--c-white);
--button-fill-danger-active-bg-color: var(--c-bg-danger-2);
--button-fill-danger-disabled-border-color: var(--c-border-mute-1);
--button-fill-danger-disabled-text-color: var(--c-text-danger-3);
--button-fill-danger-disabled-content-color: var(--c-text-danger-3);
--button-fill-danger-disabled-text-color: var(--c-text-danger-2);
--button-fill-danger-disabled-content-color: var(--c-text-danger-2);
--button-fill-danger-disabled-bg-color: var(--c-bg-mute-1);

--button-outline-default-border-color: var(--c-border-mute-1);
Expand Down
Loading

0 comments on commit 5c4061b

Please sign in to comment.