@designcrowd/fe-shared-lib 1.8.9-ai-switch-1 → 1.8.9-ai-switch-3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@designcrowd/fe-shared-lib",
3
- "version": "1.8.9-ai-switch-1",
3
+ "version": "1.8.9-ai-switch-3",
4
4
  "scripts": {
5
5
  "start": "run-p storybook watch:translation",
6
6
  "build": "npm run build:css --production",
@@ -41,6 +41,10 @@ const props = withDefaults(defineProps<Props>(), {
41
41
  showStars: false,
42
42
  });
43
43
 
44
+ const emit = defineEmits<{
45
+ toggledSwitch: [value: boolean];
46
+ }>();
47
+
44
48
  const isAi = ref(false);
45
49
 
46
50
  const ANGLE_CONST = 25;
@@ -73,9 +77,6 @@ const stars = ref([
73
77
  ]);
74
78
 
75
79
  const randomizeStars = () => {
76
- if (!isAi.value && !props.showStars) {
77
- return;
78
- }
79
80
  stars.value = Array.from({ length: NUM_STARS }, (_, index) => {
80
81
  const angle = Math.floor(
81
82
  ANGLE_CONST - index * (ANGLE_JITTER / NUM_STARS) - Math.random() * (ANGLE_JITTER / NUM_STARS),
@@ -91,11 +92,11 @@ const randomizeStars = () => {
91
92
  };
92
93
 
93
94
  const toggleSwitch = () => {
94
- // toggle left align class
95
- // if moving right to left, play star animation after movement
96
95
  isAi.value = !isAi.value;
97
- console.log(`switch clicked, now ${isAi.value}`);
98
- randomizeStars();
96
+ if (isAi.value && props.showStars) {
97
+ randomizeStars();
98
+ }
99
+ emit('toggledSwitch', isAi.value);
99
100
  };
100
101
  </script>
101
102