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

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-2",
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),
@@ -94,8 +95,10 @@ const toggleSwitch = () => {
94
95
  // toggle left align class
95
96
  // if moving right to left, play star animation after movement
96
97
  isAi.value = !isAi.value;
97
- console.log(`switch clicked, now ${isAi.value}`);
98
- randomizeStars();
98
+ if (isAi.value && props.showStars) {
99
+ randomizeStars();
100
+ }
101
+ emit.toggledSwitch = isAi.value;
99
102
  };
100
103
  </script>
101
104