-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Guillaume Chau <[email protected]>
- Loading branch information
Showing
8 changed files
with
226 additions
and
161 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Story, Variant } from '../../types' | ||
|
||
export function getSandboxUrl (story: Story, variant: Variant) { | ||
const url = new URLSearchParams() | ||
url.append('storyId', story.id) | ||
url.append('variantId', variant.id) | ||
return '/__sandbox?' + url.toString() | ||
} |
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
67 changes: 67 additions & 0 deletions
67
packages/histoire/src/client/app/components/story/variant/StoryVariantBackground.vue
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<script lang="ts" setup> | ||
import { Icon } from '@iconify/vue' | ||
import { histoireConfig } from '../../../util/config' | ||
import { usePreviewSettings } from '../../../util/preview-settings' | ||
import BaseCheckbox from '../../base/BaseCheckbox.vue' | ||
const settings = usePreviewSettings() | ||
</script> | ||
|
||
<template> | ||
<VDropdown | ||
v-if="histoireConfig.backgroundPresets.length" | ||
placement="bottom-end" | ||
:skidding="6" | ||
class="htw-h-full htw-flex-none" | ||
> | ||
<div | ||
v-tooltip="'Background color'" | ||
class="htw-cursor-pointer hover:htw-text-primary-500 htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2" | ||
> | ||
<div | ||
class="bind-preview-bg htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/50 dark:htw-border-white/50" | ||
/> | ||
<Icon | ||
icon="carbon:caret-down" | ||
class="htw-w-4 htw-h-4 htw-opacity-50" | ||
/> | ||
</div> | ||
|
||
<template #popper="{ hide }"> | ||
<div class="htw-flex htw-flex-col htw-items-stretch"> | ||
<BaseCheckbox v-model="settings.checkerboard"> | ||
Checkerboard | ||
</BaseCheckbox> | ||
|
||
<button | ||
v-for="(option, index) in histoireConfig.backgroundPresets" | ||
:key="index" | ||
class="htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4" | ||
:class="[ | ||
settings.backgroundColor === option.color | ||
? 'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black' | ||
: 'htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700', | ||
]" | ||
@click="settings.backgroundColor = option.color;hide()" | ||
> | ||
<span class="htw-mr-auto">{{ option.label }}</span> | ||
<template v-if="option.color !== '$checkerboard'"> | ||
<span class="htw-ml-auto htw-opacity-70">{{ option.color }}</span> | ||
<div | ||
class="htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/20 dark:htw-border-white/20" | ||
:style="{ | ||
backgroundColor: option.color, | ||
}" | ||
/> | ||
</template> | ||
</button> | ||
</div> | ||
</template> | ||
</VDropdown> | ||
</template> | ||
|
||
<style scoped> | ||
.bind-preview-bg { | ||
background-color: v-bind('settings.backgroundColor'); | ||
} | ||
</style> |
29 changes: 29 additions & 0 deletions
29
packages/histoire/src/client/app/components/story/variant/StoryVariantNewTab.vue
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script lang="ts" setup> | ||
import { Icon } from '@iconify/vue' | ||
import type { Story, Variant } from '../../../types' | ||
import { computed } from 'vue' | ||
import { getSandboxUrl } from '../../sandbox/lib' | ||
const props = defineProps<{ | ||
variant: Variant | ||
story: Story | ||
}>() | ||
const sandboxUrl = computed(() => { | ||
return getSandboxUrl(props.story, props.variant) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<a | ||
v-tooltip="'Open variant in new tab'" | ||
:href="sandboxUrl" | ||
target="_blank" | ||
class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 hover:htw-text-primary-500" | ||
> | ||
<Icon | ||
icon="carbon:launch" | ||
class="base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50" | ||
/> | ||
</a> | ||
</template> |
Oops, something went wrong.