@@ -73,26 +73,41 @@ export class Surface extends Root {
7373 if ( this . surface ?. styles ) {
7474 for ( const [ key , value ] of Object . entries ( this . surface . styles ) ) {
7575 switch ( key ) {
76+ // Here we generate a palette from the singular primary color received
77+ // from the surface data. We will want the values to range from
78+ // 0 <= x <= 100, where 0 = back, 100 = white, and 50 = the primary
79+ // color itself. As such we use a color-mix to create the intermediate
80+ // values.
81+ //
82+ // Note: since we use half the range for black to the primary color,
83+ // and half the range for primary color to white the mixed values have
84+ // to go up double the amount, i.e., a range from black to primary
85+ // color needs to fit in 0 -> 50 rather than 0 -> 100.
7686 case "primaryColor" : {
77- // Ignored for now. This is due to the fact that the sample agents
78- // produce values for these and if they are used here then they will
79- // override the values at the app level.
80- //
81- // for (let i = 0; i <= 100; i++) {
82- // styles[`--p-${i}`] = `color-mix(in srgb, ${value} ${
83- // 100 - i
84- // }%, #fff ${i}%)`;
85- // }
87+ styles [ "--p-100" ] = "#ffffff" ;
88+ styles [ "--p-99" ] = `color-mix(in srgb, ${ value } 2%, white 98%)` ;
89+ styles [ "--p-98" ] = `color-mix(in srgb, ${ value } 4%, white 96%)` ;
90+ styles [ "--p-95" ] = `color-mix(in srgb, ${ value } 10%, white 90%)` ;
91+ styles [ "--p-90" ] = `color-mix(in srgb, ${ value } 20%, white 80%)` ;
92+ styles [ "--p-80" ] = `color-mix(in srgb, ${ value } 40%, white 60%)` ;
93+ styles [ "--p-70" ] = `color-mix(in srgb, ${ value } 60%, white 40%)` ;
94+ styles [ "--p-60" ] = `color-mix(in srgb, ${ value } 80%, white 20%)` ;
95+ styles [ "--p-50" ] = value ;
96+ styles [ "--p-40" ] = `color-mix(in srgb, ${ value } 80%, black 20%)` ;
97+ styles [ "--p-35" ] = `color-mix(in srgb, ${ value } 70%, black 30%)` ;
98+ styles [ "--p-30" ] = `color-mix(in srgb, ${ value } 60%, black 40%)` ;
99+ styles [ "--p-25" ] = `color-mix(in srgb, ${ value } 50%, black 50%)` ;
100+ styles [ "--p-20" ] = `color-mix(in srgb, ${ value } 40%, black 60%)` ;
101+ styles [ "--p-15" ] = `color-mix(in srgb, ${ value } 30%, black 70%)` ;
102+ styles [ "--p-10" ] = `color-mix(in srgb, ${ value } 20%, black 80%)` ;
103+ styles [ "--p-5" ] = `color-mix(in srgb, ${ value } 10%, black 90%)` ;
104+ styles [ "--0" ] = "#00000" ;
86105 break ;
87106 }
88107
89108 case "font" : {
90- // Ignored for now. This is due to the fact that the sample agents
91- // produce values for these and if they are used here then they will
92- // override the values at the app level.
93- //
94- // styles["--font-family"] = value;
95- // styles["--font-family-flex"] = value;
109+ styles [ "--font-family" ] = value ;
110+ styles [ "--font-family-flex" ] = value ;
96111 break ;
97112 }
98113 }
0 commit comments