@inlaylab/opaline-vue 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,6 +19,12 @@ import { clay } from '@inlaylab/opaline/clay'
19
19
 
20
20
  Props: `seed`, `look`, `size`, `src`, `alt`, and every core option. If you mount several Vue apps on one page, give each `app.config.idPrefix` so their gradient IDs cannot clash.
21
21
 
22
+ Groups: `AvatarGroup` overlaps avatars and adds a `+N` chip past `max`.
23
+
24
+ ```vue
25
+ <AvatarGroup :look="clay" :members="[user.email, { seed: 'grace', src, alt: 'Grace' }]" :max="4" />
26
+ ```
27
+
22
28
  Same seed, same avatar: from 1.0, the same seed and options give a byte-identical SVG in every 1.x release.
23
29
 
24
30
  [Playground and docs](https://inlaylab.github.io/Opaline/) · [GitHub](https://github.com/Inlaylab/Opaline) · MIT for code and art.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AuraOptions, ClayOptions, Style } from "@inlaylab/opaline";
1
+ import { AuraOptions, ClayOptions, GroupMember, InitialsOptions, Style } from "@inlaylab/opaline";
2
2
  import { PropType } from "vue";
3
3
  type AvatarProps = {
4
4
  seed: string | number | null | undefined;
@@ -9,7 +9,7 @@ type AvatarProps = {
9
9
  src?: string;
10
10
  /** Accessible name. Without it the avatar is decorative and hidden from assistive tech. */
11
11
  alt?: string;
12
- } & ClayOptions & AuraOptions;
12
+ } & ClayOptions & AuraOptions & InitialsOptions;
13
13
  export declare const Avatar: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
14
14
  seed: {
15
15
  type: PropType<AvatarProps["seed"]>;
@@ -43,7 +43,51 @@ export declare const Avatar: import("vue").DefineComponent<import("vue").Extract
43
43
  src: StringConstructor;
44
44
  alt: StringConstructor;
45
45
  }>> & Readonly<{}>, {
46
+ size: number;
46
47
  seed: string | number | null | undefined;
48
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
49
+ type AvatarGroupProps = Omit<AvatarProps, 'seed' | 'src' | 'alt'> & {
50
+ /** Seeds, or `{ seed, src, alt }` for a photo and an accessible name. */
51
+ members: readonly GroupMember[];
52
+ /** Show at most this many avatars, then a `+N` chip. Shows everyone when unset. */
53
+ max?: number;
54
+ /** Accessible name for the whole group, e.g. "Project members". */
55
+ alt?: string;
56
+ };
57
+ /** Overlapping avatars with a `+N` chip. Style options (`palette`, `shape`, …) reach every avatar. */
58
+ export declare const AvatarGroup: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
59
+ members: {
60
+ type: PropType<readonly GroupMember[]>;
61
+ required: true;
62
+ };
63
+ look: {
64
+ type: PropType<Style<any>>;
65
+ required: true;
66
+ };
67
+ size: {
68
+ type: NumberConstructor;
69
+ default: number;
70
+ };
71
+ max: NumberConstructor;
72
+ alt: StringConstructor;
73
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
74
+ [key: string]: any;
75
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
76
+ members: {
77
+ type: PropType<readonly GroupMember[]>;
78
+ required: true;
79
+ };
80
+ look: {
81
+ type: PropType<Style<any>>;
82
+ required: true;
83
+ };
84
+ size: {
85
+ type: NumberConstructor;
86
+ default: number;
87
+ };
88
+ max: NumberConstructor;
89
+ alt: StringConstructor;
90
+ }>> & Readonly<{}>, {
47
91
  size: number;
48
92
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
49
- export type { AvatarProps };
93
+ export type { AvatarGroupProps, AvatarProps };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createAvatar } from "@inlaylab/opaline";
1
+ import { avatarGroup, createAvatar } from "@inlaylab/opaline";
2
2
  import { computed, defineComponent, h, onMounted, ref, useId } from "vue";
3
3
  // src/photo.ts
4
4
  const STYLE = {
@@ -85,4 +85,57 @@ const Avatar = defineComponent({
85
85
  }) : null]);
86
86
  }
87
87
  });
88
- export { Avatar };
88
+ // src/group.ts
89
+ /** Overlapping avatars with a `+N` chip. Style options (`palette`, `shape`, …) reach every avatar. */
90
+ const AvatarGroup = defineComponent({
91
+ name: "OpalineAvatarGroup",
92
+ inheritAttrs: false,
93
+ props: {
94
+ members: {
95
+ type: Array,
96
+ required: true
97
+ },
98
+ look: {
99
+ type: Object,
100
+ required: true
101
+ },
102
+ size: {
103
+ type: Number,
104
+ default: 40
105
+ },
106
+ max: Number,
107
+ alt: String
108
+ },
109
+ setup(props, { attrs }) {
110
+ return () => {
111
+ const g = avatarGroup(props.members, {
112
+ max: props.max,
113
+ size: props.size,
114
+ shape: attrs.shape
115
+ });
116
+ return h("span", {
117
+ "data-opaline-group": "",
118
+ role: "group",
119
+ "aria-label": props.alt || void 0,
120
+ style: g.css.root
121
+ }, [...g.shown.map((m, i) => h("span", {
122
+ key: i,
123
+ "data-opaline-member": "",
124
+ style: i ? g.css.member : g.css.first
125
+ }, [h(Avatar, {
126
+ ...attrs,
127
+ look: props.look,
128
+ size: props.size,
129
+ seed: m.seed,
130
+ src: m.src,
131
+ alt: m.alt
132
+ })])), g.rest ? h("span", {
133
+ "data-opaline-more": "",
134
+ role: "img",
135
+ "aria-label": `${g.rest} more`,
136
+ style: g.css.more
137
+ }, `+${g.rest}`) : null]);
138
+ };
139
+ }
140
+ });
141
+ export { Avatar, AvatarGroup };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inlaylab/opaline-vue",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Seeded avatars for Vue 3: an SSR-safe Avatar component.",
5
5
  "keywords": [
6
6
  "avatar",
@@ -44,7 +44,7 @@
44
44
  "vue": ">=3.5"
45
45
  },
46
46
  "dependencies": {
47
- "@inlaylab/opaline": "1.0.0"
47
+ "@inlaylab/opaline": "1.1.1"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@inlaylab/opaline-contract": "0.0.0",