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

[Component]: Breadcrumb Component (Work in progress) #861

Draft
wants to merge 57 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
00f6477
init breadcrumb developement
mouadTaoussi Mar 4, 2024
a84de3f
init breadcrumb developement
mouadTaoussi Mar 6, 2024
39ad974
init breadcrumb developement
mouadTaoussi Mar 6, 2024
2b90fe6
init breadcrumb developement
mouadTaoussi Mar 7, 2024
882ea57
init breadcrumb developement
mouadTaoussi Mar 7, 2024
6a6be85
init breadcrumb developement
mouadTaoussi Mar 8, 2024
7a4cbcc
init breadcrumb developement
mouadTaoussi Mar 10, 2024
575ff24
init breadcrumb developement
mouadTaoussi Mar 10, 2024
640d6f1
init breadcrumb developement
mouadTaoussi Mar 14, 2024
f70d7dd
init breadcrumb developement
mouadTaoussi Mar 14, 2024
09ea8d9
init breadcrumb developement
mouadTaoussi Mar 14, 2024
dd27602
init breadcrumb developement
mouadTaoussi Mar 16, 2024
e8415c6
router-link, a tags; add more elements to the docs
mouadTaoussi Mar 20, 2024
01f9753
Merge branch 'develop' of https://github.com/mouadTaoussi/oruga into …
mouadTaoussi Mar 24, 2024
8376d97
Merge branch 'oruga-ui:develop' into breadcrumb
mouadTaoussi Mar 24, 2024
acfc6ba
prepare to Pull request
mouadTaoussi Mar 24, 2024
38fb1a6
prepare to Pull request
mouadTaoussi Mar 24, 2024
152facb
Merge branch 'breadcrumb' of https://github.com/mouadTaoussi/oruga in…
mouadTaoussi Mar 24, 2024
4efbb07
add inspector to docs
mouadTaoussi Mar 24, 2024
c3dd07d
Add descriptions for each prop, and improve them
mouadTaoussi Mar 25, 2024
d184468
change class prefix
mouadTaoussi Mar 25, 2024
dcdc4b3
Merge branch 'breadcrumb' of https://github.com/mouadTaoussi/oruga in…
mouadTaoussi Mar 25, 2024
410ff47
Merge branch 'develop' into breadcrumb
mouadTaoussi Mar 26, 2024
216ca1d
change config path
mouadTaoussi Mar 26, 2024
9b173a8
Merge branch 'breadcrumb' of https://github.com/mouadTaoussi/oruga in…
mouadTaoussi Mar 26, 2024
605a9d2
Merge branch 'oruga-ui:develop' into breadcrumb
mouadTaoussi Apr 20, 2024
e7662d4
Merge branch 'oruga-ui:develop' into breadcrumb
mouadTaoussi Apr 26, 2024
984e6a8
remove unnecessary code
mouadTaoussi Apr 26, 2024
48898e9
Merge branch 'breadcrumb' of https://github.com/mouadTaoussi/oruga in…
mouadTaoussi Apr 26, 2024
d44f0e9
prettier
mouadTaoussi Apr 26, 2024
759c2f7
change examples path
mouadTaoussi Apr 28, 2024
b916416
add more examples
mouadTaoussi Apr 30, 2024
3c9c588
add more examples
mouadTaoussi Apr 30, 2024
80cbd4b
finishing
mouadTaoussi May 1, 2024
1ede02f
changed active style
mouadTaoussi May 4, 2024
a06468f
changed active style and finishing
mouadTaoussi May 5, 2024
a037ab6
prepare tests
mouadTaoussi May 5, 2024
00727cd
prepare tests
mouadTaoussi Jun 20, 2024
416de14
prepare tests
mouadTaoussi Jun 20, 2024
9f40b16
prepare tests
mouadTaoussi Jun 24, 2024
724a633
prepare tests
mouadTaoussi Jun 24, 2024
b99948d
prepare tests
mouadTaoussi Jun 25, 2024
18ddf61
prepare tests
mouadTaoussi Jul 11, 2024
a1fbf54
Merge branch 'develop' of https://github.com/oruga-ui/oruga into orug…
mouadTaoussi Jul 11, 2024
2aee214
Merge branch 'oruga-ui-develop' into breadcrumb
mouadTaoussi Jul 11, 2024
0bb9baa
merge
mouadTaoussi Jul 11, 2024
49d619a
Merge branch 'oruga-ui:develop' into breadcrumb
mouadTaoussi Jul 13, 2024
ca0069c
Merge branch 'develop' into breadcrumb
mouadTaoussi Dec 6, 2024
11191e5
merge
mouadTaoussi Dec 6, 2024
290989f
finalising
mouadTaoussi Dec 13, 2024
292c730
Merge branch 'breadcrumb' of https://github.com/mouadTaoussi/oruga in…
mouadTaoussi Dec 13, 2024
4882455
Merge branch 'oruga-ui:develop' into breadcrumb
mouadTaoussi Feb 4, 2025
879b49a
build docs
mouadTaoussi Feb 8, 2025
59b05ea
Merge branch 'oruga-ui:develop' into breadcrumb
mouadTaoussi Feb 8, 2025
48d58c5
build docs
mouadTaoussi Feb 8, 2025
f4fc3c8
Merge branch 'breadcrumb' of https://github.com/mouadTaoussi/oruga in…
mouadTaoussi Feb 8, 2025
5b8c1cb
build docs
mouadTaoussi Feb 9, 2025
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
6,447 changes: 3,127 additions & 3,320 deletions package-lock.json

Large diffs are not rendered by default.

107 changes: 107 additions & 0 deletions packages/docs/components/Breadcrumb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Breadcrumb

<div class="vp-doc">

> The classic breadcrumb, in different colors, sizes, and states

</div>

<div class="vp-example">

## Examples

<example-breadcrumb />

</div>

<div class="vp-example">

## Class props

<inspector-breadcrumb-viewer />

</div>

<div class="vp-doc">

## Breadcrumb component

> The classic breadcrumb, in different colors, sizes, and states

```html
<o-breadcrumb></o-breadcrumb>
```

### Props

| Prop name | Description | Type | Values | Default |
| ------------- | ---------------------------------------------- | -------- | --------------------------- | ---------- |
| align | Position of breadcrumb | string | `left`, `centered`, `right` | `left` |
| override | Override existing theme classes completely | boolean | | |
| size | Size of the breadcrumb | string | `small`, `medium`, `large` | `medium` |
| tag | Tag of the breadcrumb | string | `div`, `section` ... | `section` |
| separator | Separator between breadcrumb items | string | `has-arrow-separator`, `has-dot-separator`, `has-slash-separator`, `has-bullet-separator`, `has-succeeds-separator`, `has-chevron-separator` | `has-slash-separator` |

### Slots

| Name | Description | Bindings |
| ------- | ------------------------ | -------- |
| default | Display Breadcrumb items | |

</div>

<div class="vp-doc">

## Breadcrumb item component

> The classic breadcrumb item, in different colors, icons and states

```html
<o-breadcrumb-item></o-breadcrumb-item>
```

### Props

| Prop name | Description | Type | Values | Default |
| ------------- | ---------------------------------------------- | -------- | --------------------------- | ---------- |
| active | Active breadcrumb item | boolean | | `false` |
| activeVariant | Variant of active breadcrumb item | string | `primary`, `info`, `warning`, `danger` | `primary` |
| disabled | breadcrum item is disabled | boolean | | `false` |
| tag | Tag of the breadcrumb item | string | `a`, `router-link` | `a` |
| iconLeft | Icon name to show on the left | string | | |
| iconRight | Icon name to show on the right | string | | |
| iconBoth | Icon name to show on both sides | string | | |
| iconPack | Icon pack to use | string | `mdi`, `fa`, `fas` and any other custom icon pack | |

### Slots

| Name | Description | Bindings |
| ------- | --------------- | -------- |
| default | Display content | |

</div>

<div class="vp-doc">

## Sass variables

<div class="theme-oruga">

> Current theme ➜ _[Oruga](https://github.com/oruga-ui/theme-oruga)_

<p>The theme does not have any custom variables for this component.</p>
</div>
<div class="theme-bulma">

> Current theme ➜ _[Bulma](https://github.com/oruga-ui/theme-bulma)_

<p>The theme does not have any custom variables for this component.</p>
</div>
<div class="theme-bootstrap">

> Current theme ➜ _[Bootstrap](https://github.com/oruga-ui/theme-bootstrap)_

<p>The theme does not have any custom variables for this component.</p>
</div>

</div>
2 changes: 1 addition & 1 deletion packages/docs/components/Input.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Combine it with the Field component to access all functionalities.
| iconRightVariant | Variant of right icon | string | - | |
| id | Same as native id. Also set the for label for o-field wrapper - default is an uuid. | string | - | <code style='white-space: nowrap; padding: 0;'>useId()</code> |
| maxlength | Same as native maxlength, plus character counter | number \| string | - | |
| modelModifiers | | Record&lt;string, true&gt; | - | <code style='white-space: nowrap; padding: 0;'></code> |
| modelModifiers | | Partial&lt;Record&lt;string, true&gt;&gt; | - | <code style='white-space: nowrap; padding: 0;'></code> |
| v-model | The input value state | number \| string | - | |
| number | Convert the ´modelValue`into type`number` | boolean | - | <code style='white-space: nowrap; padding: 0;'></code> |
| override | Override existing theme classes completely | boolean | - | |
Expand Down
117 changes: 117 additions & 0 deletions packages/oruga/src/components/breadcrumb/Breadcrumb.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<script setup lang="ts">
import { computed, type PropType } from "vue";

import { getOption } from "@/utils/config";
import { defineClasses } from "@/composables";

import type { ComponentClass, DynamicComponent } from "@/types";

/**
* The classic breadcrumb, in different colors, sizes, and states
* @displayName Breadcrumb
* @style _breadcrumb.scss
*/
defineOptions({
isOruga: true,
name: "OBreadcrumb",
configField: "breadcrumb",
});

const props = defineProps({
/** Override existing theme classes completely */
override: { type: Boolean, default: undefined },
/**
* Size of the breadcrumb
* @values small, medium, large
*/
size: {
type: String,
default: () => getOption("breadcrumb.size", "small"),
},
/**
* Position of the breadcrumb
* @values left, centered, right
*/
align: {
mlmoravek marked this conversation as resolved.
Show resolved Hide resolved
type: String,
default: getOption("breadcrumb.align", "left"),
},
/**
* The breadcrumb separator between breadcrumb items
* @values
* has-arrow-separator, has-dot-separator, has-slash-separator, has-bullet-separator, has-succeeds-separator, has-chevron-separator
*/
separator: {
type: String,
default: () => getOption("breadcrumb.separator", "has-slash-separator"),
},
/**
* Tag of the breadcrumb
* @values div, section ...
*/
tag: {
type: [String, Object, Function] as PropType<DynamicComponent>,
default: () => getOption<DynamicComponent>("breadcrumb.tag", "section"),
},
// -----------------------------------------------------------------
/**
* This is used internally
* @ignore
*/
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary command

// class props (will not be displayed in the docs)
/** Class of the root element */
rootClass: {
type: [String, Array, Function] as PropType<ComponentClass>,
default: undefined,
},
/** Class of the breadcrumb elements wrapper */
wrapperClass: {
type: [String, Array, Function] as PropType<ComponentClass>,
default: undefined,
},
/** Class of the breadcrumb size */
sizeClass: {
type: [String, Array, Function] as PropType<ComponentClass>,
default: undefined,
},
/** Class of the breadcrumb separator */
separatorClass: {
type: [String, Array, Function] as PropType<ComponentClass>,
default: undefined,
},
/** Class of the breadcrumb align */
alignClass: {
type: [String, Array, Function] as PropType<ComponentClass>,
default: undefined,
},
});

const rootClasses = defineClasses(
["rootClass", "o-breadcrumb"],
[
"sizeClass",
"o-breadcrumb__",
computed(() => props.size),
computed(() => !!props.size),
],
[
"separatorClass",
"o-breadcrumb__",
computed(() => props.separator),
computed(() => !!props.separator),
Copy link
Member

Choose a reason for hiding this comment

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

What is the separator class for? I would think of a class on the separator element, but not on the root with a suffix.

],
[
"alignClass",
"o-breadcrumb__",
computed(() => props.align),
computed(() => !!props.align),
],
);
</script>

<template>
<component :is="tag" :class="rootClasses" data-oruga="breadcrumb">
<!-- BreadcrumbItems -->
<slot></slot>
Copy link
Member

Choose a reason for hiding this comment

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

I would like to use the component like

const route = useRoute();
<o-breadcrumb :route="route" />

And the component would render the current route with its breadcumb items.

</component>
</template>
146 changes: 146 additions & 0 deletions packages/oruga/src/components/breadcrumb/BreadcrumbItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<script setup lang="ts">
import { defineClasses } from "@/composables";

import { getOption } from "@/utils/config";

import { computed, type PropType } from "vue";
import OIcon from "../icon/Icon.vue";

import type { ComponentClass, DynamicComponent } from "@/types";

/**
* The classic breadrcumb item, in different colors, sizes, and states
* @displayName Breadcrumb Item
*/
defineOptions({
isOruga: true,
name: "OBreadcrumbItem",
configField: "breadcrumb",
inheritAttrs: true,
});

const props = defineProps({
/**
* breadcrumb item is active, works only when tag provided is a
* @values true, false
*/
active: {
type: Boolean,
default: () => getOption("breadcrumb.active"),
mlmoravek marked this conversation as resolved.
Show resolved Hide resolved
},
activeVariant: {
type: String,
default: () => getOption("breadcrumb.activeVariant"),
},
/**
* breadcrumb item tag name
* @values li, a, router-link, nuxt-link (or other nuxt alias)
*/
tag: {
type: [String, Object, Function] as PropType<DynamicComponent>,
default: () => getOption<DynamicComponent>("breadcrumb.tag", "a"),
},
/**
* breadcrumb item is disabled
* @values true, false
*/
disabled: {
type: Boolean,
default: () => getOption("breadcrumb.disabled"),
Copy link
Member

Choose a reason for hiding this comment

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

Should this be a boolean?

},
/**
* Icon pack to use
* @values mdi, fa, fas and any other custom icon pack
*/
iconPack: {
type: String,
default: () => getOption("breadcrumb.iconPack", undefined),
},
/** Icon name to show on the left */
iconLeft: { type: String, default: undefined },
/** Icon name to show on the right */
iconRight: { type: String, default: undefined },
/** Show the icon in both sides, left - right */
iconBoth: { type: Boolean, default: false },
/**
* This is used internally
* @ignore
*/
/* class props (will not be displayed in the docs) */
/** Class of the breadcrumb elements wrapper */
wrapperClass: {
type: [String, Array, Function] as PropType<ComponentClass>,
default: undefined,
},
/** Class of the breadcrumb icon */
iconClass: {
type: [String, Array, Function] as PropType<ComponentClass>,
default: undefined,
},
/** Class of the breadcrumb icon on the left */
iconLeftClass: {
type: [String, Array, Function] as PropType<ComponentClass>,
default: undefined,
},
/** Class of the breadcrumb icon on the right */
iconRightClass: {
type: [String, Array, Function] as PropType<ComponentClass>,
default: undefined,
},
});

// --- Computed Component Classes ---
const computedDisabled = computed(() =>
props.disabled ? "o-breadcrumb-item__disabled" : null,
);
const computedActive = computed(() => {
if (props.active && props.tag !== "router-link")
return `o-breadcrumb-item__${props.activeVariant} active`;
if (props.tag == "router-link")
return `o-breadcrumb-item__${props.activeVariant}`;
return null;
});
// --- Computed Component Classes ---

const iconClasses = defineClasses(["iconClass", "o-breadcrumb-item__icon"]);

const iconLeftClasses = defineClasses([
"iconLeftClass",
"o-breadcrumb-item__icon-left",
]);

const iconRightClasses = defineClasses([
"iconRightClass",
"o-breadcrumb-item__icon-right",
]);

const wrapperClasses = defineClasses([
"wrapperClass",
"o-breadcrumb-item__wrapper",
]);

const rootClasses = defineClasses(["rootClass", "o-breadcrumb-item"]);
</script>

<template>
<component
:is="tag"
:class="[rootClasses, computedActive, computedDisabled]"
data-oruga="breadcrumb-item">
<span :class="wrapperClasses">
<o-icon
v-if="iconLeft"
:pack="iconPack"
:icon="iconLeft"
:both="iconBoth"
:class="[...iconClasses, ...iconLeftClasses]" />
<slot></slot>
Copy link
Member

Choose a reason for hiding this comment

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

I would consider the sperator to be some html element.

<o-icon
v-if="iconRight"
:pack="iconPack"
:icon="iconRight"
:both="iconBoth"
:class="[...iconClasses, ...iconRightClasses]" />
</span>
</component>
</template>
Loading
Loading