@principal-ai/principal-view-react 0.6.16 → 0.6.18

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.
@@ -131,8 +131,8 @@ export const AllShapes: Story = {
131
131
  This story displays all 5 available node shapes:
132
132
  - **Rectangle** - Default shape with rounded corners (borderRadius: 8px)
133
133
  - **Circle** - Circular nodes (borderRadius: 50%)
134
- - **Hexagon** - Flat-top style with points on left/right sides
135
- - **Diamond** - Rotated 45° square with counter-rotated content
134
+ - **Hexagon** - Flat-top style using clip-path polygon
135
+ - **Diamond** - Diamond shape using clip-path polygon (works with any aspect ratio)
136
136
  - **Custom** - Placeholder that falls back to rectangle styling
137
137
  `,
138
138
  },
@@ -755,11 +755,12 @@ const ShapeComparisonTemplate = () => {
755
755
  </li>
756
756
  <li>
757
757
  <strong>Hexagon</strong>: Flat-top style using{' '}
758
- <code>clipPath: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%)</code>
758
+ <code>clipPath: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)</code>
759
759
  </li>
760
760
  <li>
761
- <strong>Diamond</strong>: Fixed square rotated 45°, inner content rotated -45° to keep
762
- text upright
761
+ <strong>Diamond</strong>: Uses{' '}
762
+ <code>clipPath: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)</code> - works with any
763
+ aspect ratio
763
764
  </li>
764
765
  <li>
765
766
  <strong>Custom</strong>: Currently renders as rectangle (placeholder for future custom
@@ -781,3 +782,427 @@ export const ShapeComparison: Story = {
781
782
  },
782
783
  },
783
784
  };
785
+
786
+ /**
787
+ * Canvas showing shapes with wide aspect ratios (width > height)
788
+ */
789
+ const wideShapesCanvas: ExtendedCanvas = {
790
+ nodes: [
791
+ {
792
+ id: 'rect-wide',
793
+ type: 'text',
794
+ x: 50,
795
+ y: 80,
796
+ width: 280,
797
+ height: 60,
798
+ text: 'Wide Rectangle (280x60)',
799
+ color: 6,
800
+ pv: {
801
+ nodeType: 'rect-wide',
802
+ shape: 'rectangle',
803
+ icon: 'RectangleHorizontal',
804
+ },
805
+ },
806
+ {
807
+ id: 'circle-wide',
808
+ type: 'text',
809
+ x: 380,
810
+ y: 80,
811
+ width: 280,
812
+ height: 60,
813
+ text: 'Wide Circle (280x60)',
814
+ color: 5,
815
+ pv: {
816
+ nodeType: 'circle-wide',
817
+ shape: 'circle',
818
+ icon: 'Circle',
819
+ },
820
+ },
821
+ {
822
+ id: 'hex-wide',
823
+ type: 'text',
824
+ x: 50,
825
+ y: 180,
826
+ width: 280,
827
+ height: 60,
828
+ text: 'Wide Hexagon (280x60)',
829
+ color: 4,
830
+ pv: {
831
+ nodeType: 'hex-wide',
832
+ shape: 'hexagon',
833
+ icon: 'Hexagon',
834
+ },
835
+ },
836
+ {
837
+ id: 'diamond-wide',
838
+ type: 'text',
839
+ x: 380,
840
+ y: 180,
841
+ width: 280,
842
+ height: 60,
843
+ text: 'Wide Diamond (280x60)',
844
+ color: 2,
845
+ pv: {
846
+ nodeType: 'diamond-wide',
847
+ shape: 'diamond',
848
+ icon: 'Diamond',
849
+ },
850
+ },
851
+ // Extra wide versions
852
+ {
853
+ id: 'rect-extra-wide',
854
+ type: 'text',
855
+ x: 50,
856
+ y: 280,
857
+ width: 400,
858
+ height: 50,
859
+ text: 'Extra Wide Rectangle (400x50)',
860
+ color: 6,
861
+ pv: {
862
+ nodeType: 'rect-extra-wide',
863
+ shape: 'rectangle',
864
+ icon: 'RectangleHorizontal',
865
+ },
866
+ },
867
+ {
868
+ id: 'hex-extra-wide',
869
+ type: 'text',
870
+ x: 50,
871
+ y: 360,
872
+ width: 400,
873
+ height: 50,
874
+ text: 'Extra Wide Hexagon (400x50)',
875
+ color: 4,
876
+ pv: {
877
+ nodeType: 'hex-extra-wide',
878
+ shape: 'hexagon',
879
+ icon: 'Hexagon',
880
+ },
881
+ },
882
+ ],
883
+ edges: [],
884
+ pv: {
885
+ version: '1.0.0',
886
+ name: 'Wide Shapes Audit',
887
+ description: 'Node shapes with wide aspect ratios',
888
+ edgeTypes: {},
889
+ },
890
+ };
891
+
892
+ export const WideShapes: Story = {
893
+ args: {
894
+ canvas: wideShapesCanvas,
895
+ width: 750,
896
+ height: 480,
897
+ },
898
+ parameters: {
899
+ docs: {
900
+ description: {
901
+ story: `
902
+ **Wide Aspect Ratio Shapes**
903
+
904
+ Tests how each shape handles wide aspect ratios (width >> height):
905
+ - **Row 1**: Wide shapes at 280x60
906
+ - **Row 2**: Wide shapes at 280x60
907
+ - **Row 3-4**: Extra wide shapes at 400x50
908
+
909
+ Use this to audit:
910
+ - How circle handles non-square dimensions (should it force square or stretch?)
911
+ - How hexagon clip-path scales horizontally
912
+ - How diamond rotation works with rectangular dimensions
913
+ `,
914
+ },
915
+ },
916
+ },
917
+ };
918
+
919
+ /**
920
+ * Canvas showing shapes with tall aspect ratios (height > width)
921
+ */
922
+ const tallShapesCanvas: ExtendedCanvas = {
923
+ nodes: [
924
+ {
925
+ id: 'rect-tall',
926
+ type: 'text',
927
+ x: 50,
928
+ y: 50,
929
+ width: 80,
930
+ height: 200,
931
+ text: 'Tall Rect',
932
+ color: 6,
933
+ pv: {
934
+ nodeType: 'rect-tall',
935
+ shape: 'rectangle',
936
+ icon: 'RectangleVertical',
937
+ },
938
+ },
939
+ {
940
+ id: 'circle-tall',
941
+ type: 'text',
942
+ x: 180,
943
+ y: 50,
944
+ width: 80,
945
+ height: 200,
946
+ text: 'Tall Circle',
947
+ color: 5,
948
+ pv: {
949
+ nodeType: 'circle-tall',
950
+ shape: 'circle',
951
+ icon: 'Circle',
952
+ },
953
+ },
954
+ {
955
+ id: 'hex-tall',
956
+ type: 'text',
957
+ x: 310,
958
+ y: 50,
959
+ width: 80,
960
+ height: 200,
961
+ text: 'Tall Hex',
962
+ color: 4,
963
+ pv: {
964
+ nodeType: 'hex-tall',
965
+ shape: 'hexagon',
966
+ icon: 'Hexagon',
967
+ },
968
+ },
969
+ {
970
+ id: 'diamond-tall',
971
+ type: 'text',
972
+ x: 440,
973
+ y: 50,
974
+ width: 80,
975
+ height: 200,
976
+ text: 'Tall',
977
+ color: 2,
978
+ pv: {
979
+ nodeType: 'diamond-tall',
980
+ shape: 'diamond',
981
+ icon: 'Diamond',
982
+ },
983
+ },
984
+ // Extra tall versions
985
+ {
986
+ id: 'rect-extra-tall',
987
+ type: 'text',
988
+ x: 570,
989
+ y: 50,
990
+ width: 60,
991
+ height: 280,
992
+ text: 'Extra Tall',
993
+ color: 6,
994
+ pv: {
995
+ nodeType: 'rect-extra-tall',
996
+ shape: 'rectangle',
997
+ icon: 'RectangleVertical',
998
+ },
999
+ },
1000
+ {
1001
+ id: 'hex-extra-tall',
1002
+ type: 'text',
1003
+ x: 680,
1004
+ y: 50,
1005
+ width: 60,
1006
+ height: 280,
1007
+ text: 'Extra Tall',
1008
+ color: 4,
1009
+ pv: {
1010
+ nodeType: 'hex-extra-tall',
1011
+ shape: 'hexagon',
1012
+ icon: 'Hexagon',
1013
+ },
1014
+ },
1015
+ ],
1016
+ edges: [],
1017
+ pv: {
1018
+ version: '1.0.0',
1019
+ name: 'Tall Shapes Audit',
1020
+ description: 'Node shapes with tall aspect ratios',
1021
+ edgeTypes: {},
1022
+ },
1023
+ };
1024
+
1025
+ export const TallShapes: Story = {
1026
+ args: {
1027
+ canvas: tallShapesCanvas,
1028
+ width: 800,
1029
+ height: 400,
1030
+ },
1031
+ parameters: {
1032
+ docs: {
1033
+ description: {
1034
+ story: `
1035
+ **Tall Aspect Ratio Shapes**
1036
+
1037
+ Tests how each shape handles tall aspect ratios (height >> width):
1038
+ - **Columns 1-4**: Tall shapes at 80x200
1039
+ - **Columns 5-6**: Extra tall shapes at 60x280
1040
+
1041
+ Use this to audit:
1042
+ - How circle handles non-square dimensions
1043
+ - How hexagon clip-path scales vertically
1044
+ - How diamond rotation works with tall rectangular dimensions
1045
+ - Text/icon placement in narrow vertical spaces
1046
+ `,
1047
+ },
1048
+ },
1049
+ },
1050
+ };
1051
+
1052
+ /**
1053
+ * Canvas showing extreme aspect ratios for stress testing
1054
+ */
1055
+ const extremeAspectRatiosCanvas: ExtendedCanvas = {
1056
+ nodes: [
1057
+ // Very wide row
1058
+ {
1059
+ id: 'rect-very-wide',
1060
+ type: 'text',
1061
+ x: 50,
1062
+ y: 50,
1063
+ width: 500,
1064
+ height: 40,
1065
+ text: 'Very Wide Rectangle (500x40) - Testing extreme horizontal stretch',
1066
+ color: 6,
1067
+ pv: {
1068
+ nodeType: 'rect-very-wide',
1069
+ shape: 'rectangle',
1070
+ },
1071
+ },
1072
+ {
1073
+ id: 'hex-very-wide',
1074
+ type: 'text',
1075
+ x: 50,
1076
+ y: 120,
1077
+ width: 500,
1078
+ height: 40,
1079
+ text: 'Very Wide Hexagon (500x40) - Testing clip-path at extremes',
1080
+ color: 4,
1081
+ pv: {
1082
+ nodeType: 'hex-very-wide',
1083
+ shape: 'hexagon',
1084
+ },
1085
+ },
1086
+ // Very tall column
1087
+ {
1088
+ id: 'rect-very-tall',
1089
+ type: 'text',
1090
+ x: 600,
1091
+ y: 50,
1092
+ width: 50,
1093
+ height: 300,
1094
+ text: 'Very Tall',
1095
+ color: 6,
1096
+ pv: {
1097
+ nodeType: 'rect-very-tall',
1098
+ shape: 'rectangle',
1099
+ },
1100
+ },
1101
+ {
1102
+ id: 'hex-very-tall',
1103
+ type: 'text',
1104
+ x: 700,
1105
+ y: 50,
1106
+ width: 50,
1107
+ height: 300,
1108
+ text: 'Very Tall',
1109
+ color: 4,
1110
+ pv: {
1111
+ nodeType: 'hex-very-tall',
1112
+ shape: 'hexagon',
1113
+ },
1114
+ },
1115
+ // Circle and diamond with extreme ratios (should these enforce square?)
1116
+ {
1117
+ id: 'circle-extreme-wide',
1118
+ type: 'text',
1119
+ x: 50,
1120
+ y: 200,
1121
+ width: 200,
1122
+ height: 40,
1123
+ text: 'Circle Wide?',
1124
+ color: 5,
1125
+ pv: {
1126
+ nodeType: 'circle-extreme-wide',
1127
+ shape: 'circle',
1128
+ },
1129
+ },
1130
+ {
1131
+ id: 'diamond-extreme-wide',
1132
+ type: 'text',
1133
+ x: 300,
1134
+ y: 200,
1135
+ width: 200,
1136
+ height: 40,
1137
+ text: 'Diamond Wide?',
1138
+ color: 2,
1139
+ pv: {
1140
+ nodeType: 'diamond-extreme-wide',
1141
+ shape: 'diamond',
1142
+ },
1143
+ },
1144
+ {
1145
+ id: 'circle-extreme-tall',
1146
+ type: 'text',
1147
+ x: 50,
1148
+ y: 280,
1149
+ width: 50,
1150
+ height: 120,
1151
+ text: 'Tall?',
1152
+ color: 5,
1153
+ pv: {
1154
+ nodeType: 'circle-extreme-tall',
1155
+ shape: 'circle',
1156
+ },
1157
+ },
1158
+ {
1159
+ id: 'diamond-extreme-tall',
1160
+ type: 'text',
1161
+ x: 150,
1162
+ y: 280,
1163
+ width: 50,
1164
+ height: 120,
1165
+ text: 'Tall?',
1166
+ color: 2,
1167
+ pv: {
1168
+ nodeType: 'diamond-extreme-tall',
1169
+ shape: 'diamond',
1170
+ },
1171
+ },
1172
+ ],
1173
+ edges: [],
1174
+ pv: {
1175
+ version: '1.0.0',
1176
+ name: 'Extreme Aspect Ratios',
1177
+ description: 'Stress testing node shapes with extreme dimensions',
1178
+ edgeTypes: {},
1179
+ },
1180
+ };
1181
+
1182
+ export const ExtremeAspectRatios: Story = {
1183
+ args: {
1184
+ canvas: extremeAspectRatiosCanvas,
1185
+ width: 800,
1186
+ height: 450,
1187
+ },
1188
+ parameters: {
1189
+ docs: {
1190
+ description: {
1191
+ story: `
1192
+ **Extreme Aspect Ratios (Stress Test)**
1193
+
1194
+ Tests shapes at extreme aspect ratios to identify edge cases:
1195
+ - **500x40**: Very wide shapes
1196
+ - **50x300**: Very tall shapes
1197
+ - Circle with non-square dimensions (should it enforce square or stretch?)
1198
+
1199
+ Key questions to answer:
1200
+ 1. Does circle force equal width/height or stretch?
1201
+ 2. Does hexagon clip-path degrade gracefully at extremes?
1202
+ 3. Does diamond clip-path work correctly at extremes?
1203
+ 4. Is text readable in narrow/short shapes?
1204
+ `,
1205
+ },
1206
+ },
1207
+ },
1208
+ };